user8120579
user8120579

Reputation: 31

Specify Encoding Format when Export DataTable to Excel with Open Xml SDK in c#

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

Upvotes: 2

Views: 1261

Answers (1)

FortyTwo
FortyTwo

Reputation: 2649

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

Upvotes: 2

Related Questions