在c#中使用Open Xml SDK将数据表导出到Excel时指定编码格式 [英] Specify Encoding Format when Export DataTable to Excel with Open Xml SDK in c#

查看:137
本文介绍了在c#中使用Open Xml SDK将数据表导出到Excel时指定编码格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想使用开放xml将数据表导出为ex​​cel.参考以下方法,

I am just trying to export datatable as excel using open xml. Referred the below approach,

使用Open Xml将数据表导出到Excel c#

但是我无法指定创建的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆