问题
I am just trying to export datatable as excel using open xml. Referred the below approach,
Export DataTable to Excel with Open Xml SDK in c#
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.
Can some one help on how could the formatting specificed using Open XML
回答1:
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.
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
来源:https://stackoverflow.com/questions/44393927/specify-encoding-format-when-export-datatable-to-excel-with-open-xml-sdk-in-c-sh