How to create one HTML file for viewing in Excel with multiple sheets?

I would like to know if it is possible to create one HTML file which (after changing the extension to .xls) when opened with Excel will be parsed into several sheets.

A small example:

I have a test.xls file with 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 in Excel, I get one sheet with the calculated sum of cells A1-C1 in A4 = 6.

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

Here is an example Excel of this file: enter image description here

+4
source share
1 answer

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

You can save an Excel document with multiple spreadsheets as HTML, and then convert it to find out which part you need to change (this is easy to do).

To save a document with multiple tables as an html document: File> Save As> Web Page (* .htm, * .html) The disadvantage of this method is that it will create several files.

If you need 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 open these files )

Learn more about office.microsoft.com

EDIT: I have not posted any code here since it is very long (excel automatically adds some code to the file) EDIT2: If you are creating a program for this, I would recommend using existing libraries such as excellibrary

+1
source

Source: https://habr.com/ru/post/1488043/


All Articles