其實我們完全可以按照上次的說明,生成一個MIME格式描述的Excel檔案先,然後加入對多sheet的描述就可以了。對多sheet支援的MIME描述是檔案中一個單獨的節,如下是一個描述了4個sheets的節:

------BOUNDARY_9527----

Content-Location: file:///C:/0E8D990C/MimeExcel.xml

Content-Transfer-Encoding: quoted-printable

Content-Type: text/html; charset="us-ascii"


<html xmlns:o=3D"urn:schemas-microsoft-com:office:office"

xmlns:x=3D"urn:schemas-microsoft-com:office:excel"

xmlns=3D"http://www.w3.org/TR/REC-html40">


<head>

<xml>

<x:ExcelWorkbook>

<x:ExcelWorksheets>

<x:ExcelWorksheet>

<x:Name>cnblogs</x:Name>

<x:WorksheetSource HRef=3D"cid:sheet001"/>

</x:ExcelWorksheet>


<x:Name>birdshome</x:Name>

<x:WorksheetSource HRef=3D"cid:sheet002"/>



<x:Name>mime</x:Name>

<x:WorksheetSource HRef=3D"MimeExcel/sheet003.xml"/>



<x:Name>excel</x:Name>

<x:WorksheetSource HRef=3D"MimeExcel/sheet004.xml"/>


</x:ExcelWorksheets>

</x:ExcelWorkbook>

</xml>

</head>

</html>
其實最關鍵的就是<x:WorksheetSource HRef=3D"cid:sheet002"/>節點,它的屬性HRef表示一個Sheet的ID,這個ID和上次說的圖檔引用一樣,可以使Content-Location描述,也可是Content-ID來描述,隻要引用的時候注意配對就行了。


Content-ID: sheet001










<x:WorksheetOptions>

<x:ProtectContents>False</x:ProtectContents>

<x:ProtectObjects>False</x:ProtectObjects>

<x:ProtectScenarios>False</x:ProtectScenarios>

</x:WorksheetOptions>



<body>

<table>

<tr>

<td>cnblogs</td>




</tr>

</table>

</body>

本文轉自部落格園鳥食軒的部落格,原文連結:http://www.cnblogs.com/birdshome/,如需轉載請自行聯系原部落客。