Your problem is the mis-mat" />
乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > C# 的NPOI导出的Excel乱码,版本是NPOI 2.2...-c nopi 导出excel,怎样导出excel表格

C# 的NPOI导出的Excel乱码,版本是NPOI 2.2...-c nopi 导出excel,怎样导出excel表格

作者:乔山办公网日期:

返回目录:excel表格制作


using (ms = new MemoryStream()) //这里至少要设置文件名啊

Your problem is the mis-match of these two lines
XSSFWorkbook workbook = new XSSFWorkbook();

and
response.setContentType("application/vnd.ms-excel");

If you really want to generate a .xls older-style Excel workbook, you need to change the first line to be HSSFWorkbook rather than XSSFWorkbook
If you do mean to generate a .xlsx Excel workbook, then the content type on the second line needs to be the correct .xlsx one, which would be:
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
推荐下面免费的方法试试:
方法一:使用虚拟打印机pdf factory即可,而且其他格式文件只要是能够打印,选择这个虚拟打印机,都可以做成PDF文件,很简单实用;
方法二:使用专门的转换软件,把文件转成PDF文件;
方法三:用其他虚拟打印机转成PDF文件。
方法四:用WPS本身自带的转换功能zhidao转成PDF文件。

字符编解码的问题吧。

这样试试

string name = Encoding.UTF8.GetString(Encoding.Default.GetBytes("姓名"));
headerRow.CreateCell(0, CellType.String).SetCellValue(name);

相关阅读

关键词不能为空
极力推荐
  • <em>excel2013</em>怎么设置数据<em>有效性</em>

  • 鼠标停在B2单元格,点击主菜单:“数据”、“有效性”,在抄弹出框中:“允许“下拉框中选择“序列”;”来源”框中输入:男,女 注意逗号是英文半角状态 的,关闭汉字输入法

ppt怎么做_excel表格制作_office365_word文档_365办公网