How create single HTML file to viewed in Excel with multiple sheets?

两盒软妹~` 提交于 2019-12-22 08:59:55

问题


I would like to know if it is possible to create a single HTML file which (after changing its extension to .xls) when opened with Excel, will parsed to multiple sheets.

Little example :

I've got a file test.xls with the content :

<html>
<body>
<table>
<tr>
 <td>
 1
 </td>
 <td>
 2
 </td>
 <td>
 3
 </td>
 <td>
 =sum(A1:C1)
 </td>

</tr>
</table>
</body>
</html>

When I open this file with Excel I get one Sheet with calculated sum of cells A1 to C1 in A4=6.

I wonder if it is possible to create an HTML file which contains multiple tables which will be parsed as multiple sheets in Excel.

Here is the Excel view of this file :


回答1:


Yes, it is possible.
However keep in mind that you might not have some features/formatting due to the limitations of this format.

You can save an Excel document with several spreadsheets as HTML, and then reverse engineer it to figure out which part you have to change (it is easy to do).

To save a document with several spreadsheets as html document : File > Save As > Web Page (*.htm, *.html) The drawback of this method is that it will produce several files.

If you want a unique file, use File > Save As > Single File Web Page (*.mht; *.mhl) This will create a unique file (.mht) that you can open with a browser if you want (most browsers do open these files).

More details on office.microsoft.com

EDIT: I did not post any code here since it is very long (excel automatically adds some code into the file) EDIT2: If you're creating a programm to do this, I would recommend that you use already existing libraries, such as excellibrary



来源:https://stackoverflow.com/questions/17294770/how-create-single-html-file-to-viewed-in-excel-with-multiple-sheets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!