繁体   English   中英

在C#中格式化Excel工作表

[英]format excel sheet in c#

我想格式化我的c#应用程序生成的excel工作表,按照模板excel /源excel工作表的格式。

我已经使用Linq to XML和将Excel工作簿另存为XML时使用的SpreadsheetML格式完成了此操作。 基本上,您可以创建格式电子表格,但是需要它。 然后,将其另存为XML。 您找到要以编程方式更改的区域,然后使用Linq to XML进行更改。 识别电子表格中有趣区域的最简单方法是使用标记的单元格。

SpreadsheetML可能会变得非常复杂,但是该方法在过去对我有用。

使用Interop.Excel程序集方法 ),可以在创建新工作簿时加载excel模板:

Microsoft.Office.Interop.Excel.Application xlApp = new Application();
Microsoft.Office.Interop.Excel.Workbook wb = xlApp.Workbooks.Open("excelTemplateFile.xls",
            Type.Missing, Type.Missing, Type.Missing, Type.Missing,
            Type.Missing, Type.Missing, Type.Missing, Type.Missing,
            Type.Missing, Type.Missing, Type.Missing, Type.Missing,
            Type.Missing, Type.Missing);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM