Excel操作帮助类 (基于Aspose.Cells.dll)
2017-11-14 11:54
405 查看
基于Aspose.Cells.dll 封装了对于导出的Excel的各种样式设置,内容填充操作,目前支持边框样式,颜色,字体,合并单元格等操作,简化Aspose.Cells.dll的使用
调用示例
导出例子
GitHub地址
2017/11/15更新后 不再对所谓的标题行标题列作区分(在ExcelFormat对象中只保留SCells属性,即可配置样式的单元格集合。除此之外,新增了数据行,数据列,数据区块的概念,方便一组规则且具有相同样式的数据区块插入。为确保配置样式和插入的灵活性,所有的单元格最终汇总到SCells中等待写入)
调用示例
/// ---------->Clom Y /// | /// | /// | /// \/ Row X static void Main(string[] args) { object[] clom = { "列名1", "列名2", "列名3" }; object[] row = { "行名1", "行名2", "行名3", "行名4" }; String filename = "text.xlsx"; //列标题样式 CellStyle Styleclom = new CellStyle(); Styleclom.AllBorder = Aspose.Cells.CellBorderType.Thin; Styleclom.ForegroundColor = Color.Yellow; Styleclom.IsBold = true; //行标题样式 CellStyle Stylerow = new CellStyle(); Stylerow.AllBorder = Aspose.Cells.CellBorderType.Thin; Stylerow.ForegroundColor = Color.ForestGreen; Stylerow.IsBold = true; //单元格样式 CellStyle Stylebody = new CellStyle(); Stylebody.AllBorder = Aspose.Cells.CellBorderType.Medium; Stylebody.ForegroundColor = Color.LightBlue; Stylebody.IsBold = true; Stylebody.IsItalic = true; //将样式和内容填充到模板中 ExcelFormat eformat = new ExcelFormat(); eformat.SavePath = filename; eformat.ColumnsSize = 20; eformat.RowsSize = 20; //直接插入标题 //eformat.InsertTitle(clom.ToList(), Styleclom, ExcelFormat.TitleType.列标题); //eformat.InsertTitle(row.ToList(), Stylerow, ExcelFormat.TitleType.行标题); eformat.InsertCellRow(new CellRow(1, 4, 0, clom.ToList()), Stylerow); eformat.InsertCellColm(new CellColm(1, 5, 0, row.ToList()), Styleclom); for (int i = 0; i < clom.Length; i++) { for (int j = 0; j < row.Length; j++) { SCell scell = new SCell(); scell.Txt_Obj = Convert.ToString(row[j]) + Convert.ToString(row[i]); scell.X = j + 1; scell.Y = i + 1; scell.CStyle = Stylebody; eformat.SCells.Add(scell); } } //向Excel中写入数据 ExcelMethod.InsertData(eformat, true); Console.WriteLine("完毕"); Console.ReadLine(); }
导出例子
GitHub地址
2017/11/15更新后 不再对所谓的标题行标题列作区分(在ExcelFormat对象中只保留SCells属性,即可配置样式的单元格集合。除此之外,新增了数据行,数据列,数据区块的概念,方便一组规则且具有相同样式的数据区块插入。为确保配置样式和插入的灵活性,所有的单元格最终汇总到SCells中等待写入)
相关文章推荐
- excel 在线预览类库:Aspose.Cells.dll
- 对Aspose.Cells Excel文件操作的扩展
- C# 读写Excel的一些方法,Aspose.Cells.dll
- C# 基于Aspose.Cells的数据导出到Excel
- NPOI、MyXls、Aspose.Cells 导入导出Excel(转)
- Aspose.Cells操作说明中文版下载/Aspose.Cells.dll(for .net)下载 /Aspose C# 导出Excel 实例
- 根据路径获得文件名以及Aspose.Cells.dll操作excel 以及使用iTextSharp.text.pdf.PdfReader.dll对PDF的操作
- NPOI、MyXls、Aspose.Cells 导入导出Excel
- 关于Aspose对于Word操作的一些扩展及思考
- AsposeExcel
- 基于POI操作Excel的导入导出
- 将VBA操作封装为DLL组件并在EXCEL中调用
- ppt 在线预览类库:Aspose.Slides.dll
- 【转载】Excel操作 Microsoft.Office.Interop.Excel.dll的使用
- Excel操作 Microsoft.Office.Interop.Excel.dll的使用
- java基于poi实现快速操作Excel的工具[v2.1.0]版本更新
- 基于Aspose.Words 生成Word文件
- ASP.NET基于Aspose.Words插入Word水印以及多个水印
- Excel操作类库 Aspose.Cell.dll[转]
- c#操作excel方式三:使用Microsoft.Office.Interop.Excel.dll读取Excel文件