用MIME格式描述多工作表Excel文件无法设置中文表名的问题

兵工厂三剑客 2017-11-22 05:41:42
现在有个需求,要在C/S客户端,导出多个网页表格中的内容到一个Excel表格中去,每个网页占一个Sheet页。现在有个问题,我把每个网页的内容导入到每个Sheet了,但是Sheet的表名无法设置成中文,只能设置成英文或者数字。

导出的代码(Table部分被我简化了)如下:


MIME-Version: 1.0
X-Document-Type: Workbook
Content-Type: multipart/related; boundary="----=BOUNDARY_MSDN"

------=BOUNDARY_MSDN
Content-Type: text/html; charset="utf-8"

<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel">

<head>
<xml>
<o:DocumentProperties>
<o:Author>心冷熱情熄</o:Author>
<o:LastAuthor>心冷熱情熄</o:LastAuthor>
<o:Created>2007-07-10T17:02:17Z</o:Created>
<o:LastSaved>2007-07-10T17:06:05Z</o:LastSaved>
<o:Company>MSDN</o:Company>
<o:Version>11.5606</o:Version>
</o:DocumentProperties>
</xml>
<xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
<x:ExcelWorksheet>
<x:Name>表1</x:Name>
<x:WorksheetSource HRef="cid:sheet01"/>
</x:ExcelWorksheet>
<x:ExcelWorksheet>
<x:Name>表2</x:Name>
<x:WorksheetSource HRef="cid:sheet02"/>
</x:ExcelWorksheet>
</x:ExcelWorksheets>
</x:ExcelWorkbook>
</xml>
</head>
</html>

------=BOUNDARY_MSDN
Content-ID: sheet01
Content-Type: text/html; charset="utf-8"

<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel">

<head>
<xml>
<x:WorksheetOptions>
<x:ProtectContents>False</x:ProtectContents>
<x:ProtectObjects>False</x:ProtectObjects>
<x:ProtectScenarios>False</x:ProtectScenarios>
</x:WorksheetOptions>
</xml>
</head>
<body>
<table>
<tr>
<td>1</td>
</tr>
<tr>
<td>a2</td>
</tr>
</table>
</body>
</html>

------=BOUNDARY_MSDN
Content-ID: sheet02
Content-Type: text/html; charset="utf-8"

<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel">

<head>
<xml>
<x:WorksheetOptions>
<x:ProtectContents>False</x:ProtectContents>
<x:ProtectObjects>False</x:ProtectObjects>
<x:ProtectScenarios>False</x:ProtectScenarios>
</x:WorksheetOptions>
</xml>
</head>
<body>
<table>
<tr>
<td>a1</td>
<td>2</td>
</tr>
<tr>
<td>a2</td>
<td>b2</td>
</tr>
</table>
</body>
</html>

------=BOUNDARY_MSDN--




问题就是<x:Name>表1</x:Name>这个地方,只要是汉字就显示成了乱码。请问大神们,怎么正确显示中文。
...全文
455 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

17,740

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 .NET Framework
社区管理员
  • .NET Framework社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧