在c#中使用Open Xml SDK将数据表导出到Excel时指定编码格式 [英] Specify Encoding Format when Export DataTable to Excel with Open Xml SDK in c#
问题描述
我只是想使用开放xml将数据表导出为excel.参考以下方法,
I am just trying to export datatable as excel using open xml. Referred the below approach,
但是我无法指定创建的excel的编码格式.我想保存或创建具有UTF-Encoding-8格式的摘录.
But I couldn't specify the encoding format of the excel created. I want to save or create the excecl with UTF-Encoding-8 format.
请问一个有关如何使用Open XML规范格式的帮助
Can some one help on how could the formatting specificed using Open XML
推荐答案
要使用UTF-Encoding-8格式保存Excel文件,您需要在工具-> 下指定编码格式Web选项-> 编码,同时保存excel文件.
To save an Excel file with UTF-Encoding-8 Format you need to specify the encoding format under Tools -> Web Options -> Encoding while saving the excel file.
使用OpenXML,您需要创建一个新的WebPublishing
并将其添加到Workbook
.
With OpenXML you need to create a new WebPublishing
and add it to Workbook
.
WebPublishing webPublishing1 = new WebPublishing(){ AllowPng = true, TargetScreenSize = TargetScreenSizeValues.Sz1024x768, CodePage = (UInt32Value)65001U };
workbook1.Append(webPublishing1);
//Where workbook1 is WorkbookPart.Workbook
这篇关于在c#中使用Open Xml SDK将数据表导出到Excel时指定编码格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!