Question

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 : enter image description here

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top