131 lines
3.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Spreadsheet;
namespace IronIntel.Contractor
{
/// <summary>
/// 单元格数据类型
/// </summary>
public enum CellDataType
{
String, Bool, Date, Guid, Float, Integer
}
/// <summary>
/// 单元格格式类型
/// </summary>
public enum CellFormatType
{
CSharp, Excel
}
#region Cell Border
public enum EBorder
{
None, Single, Double
}
public class CellBorder
{
public LeftBorder LeftBorder { get; set; }
public RightBorder RightBorder { get; set; }
public TopBorder TopBorder { get; set; }
public BottomBorder BottomBorder { get; set; }
public DiagonalBorder DialogalBorder { get; set; }
}
#endregion
/// <summary>
/// 单元格对齐方式
/// </summary>
#region cell alignment
public class CellAlignment
{
public Alignment Align { get; set; }
}
#endregion
/// <summary>
/// 单元格填充颜色
/// </summary>
#region cell fill
public class CellFill
{
public System.Drawing.Color FillColor { get; set; }
}
#endregion
/// <summary>
/// 单元格字体
/// </summary>
#region cell font
public class CellFont
{
public string FontName { get; set; }
public DoubleValue FontSize { get; set; }
public BooleanValue IsBold { get; set; }
public System.Drawing.Color ForeColor { get; set; }
}
#endregion
/// <summary>
/// 单元格样式和数据。
/// </summary>
public interface IOpenXmlExcelStyleAndData
{
//单元格数据值
object Value { get; set; }
//单元格数据类型
CellDataType DataType { get; set; }
//单元格数据颜色
CellFont CFont { get; set; }
//单元格数据格式
CellFormatType FormatType { get; set; }
String FormatCode { get; set; }
//单元格边界样式
CellBorder CBorder { get; set; }
//单元格对齐方式
CellAlignment CAlignment { get; set; }
//填充颜色
CellFill CFill { get; set; }
//合并单元格需要合并的
String MergedCellsPosition { get; set; }
}
/// <summary>
/// excel sheet 数据和样式集合。
/// </summary>
public class COpenXmlExcelSheet
{
public List<List<IOpenXmlExcelStyleAndData>> DataMatrix
{
get;
set;
}
private List<double> _WidthList = new List<double>();
public List<double> WidthList
{
get { return _WidthList; }
}
Dictionary<int, double> _RowHeightList = new Dictionary<int, double>();
public Dictionary<int, double> RowHeightList
{
get { return _RowHeightList; }
}
}
}