java - File using Office XML Schema no longer reliably opened by Excel - Stack Overflow

For many years I have been exporting HTML tables from my web app and downloading them as XSLX so that t

For many years I have been exporting HTML tables from my web app and downloading them as XSLX so that they will be opened by Excel.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" ".dtd">
<html xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:xalan=";>
<head></head>
<body>
    <table>
       ...
    </table>
</body>
</html>

Up until recently this has worked well (ignoring a warning message that the format does not match the file extension).

I am now getting complaints from users who have "upgraded to Windows 11". Excel (2016) starts but does not get beyond the splash screen. If I kill the Excel process and try to open the file it may or may not open. It seems very hit or miss and I'm finding it difficult to get a handle on the problem.

I realise that what I've been doing is not the very best solution but, for me, it was very convenient. I could simply append an Excel icon to the table, handle the click and send the table html to a servlet where it gets wrapped (see above) before downloading.

What might be causing Excel now to have a problem? What alternatives are there to package an HTML table and to be able to open it in Excel?

For many years I have been exporting HTML tables from my web app and downloading them as XSLX so that they will be opened by Excel.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3./TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:xalan="http://xml.apache./xslt">
<head></head>
<body>
    <table>
       ...
    </table>
</body>
</html>

Up until recently this has worked well (ignoring a warning message that the format does not match the file extension).

I am now getting complaints from users who have "upgraded to Windows 11". Excel (2016) starts but does not get beyond the splash screen. If I kill the Excel process and try to open the file it may or may not open. It seems very hit or miss and I'm finding it difficult to get a handle on the problem.

I realise that what I've been doing is not the very best solution but, for me, it was very convenient. I could simply append an Excel icon to the table, handle the click and send the table html to a servlet where it gets wrapped (see above) before downloading.

What might be causing Excel now to have a problem? What alternatives are there to package an HTML table and to be able to open it in Excel?

Share Improve this question asked Mar 25 at 11:54 paulpaul 13.5k24 gold badges85 silver badges155 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

The only reliable solution is to finally do the HTML to XLSX conversion.

There is open source code.

But one can do-it-yourself as .xlsx is a zip format with undermore XML files.

Edit a template.xslx, rename it to .zip and extract it.

  • xl/
    • worksheets/
      • sheet1.xml
    • sharedStrings.xml

Unique (!) cell values are stored in sharedStrings.xml and a reference to it is used in sheet1.xml.

You must program zipping the filled in XMLs again.

In the past one could also use the SYLK format, and possible one could use an onld XLS/XLSX format that actually is XML but the solution above seems to guarantee more continuity.

See it as technical debt, sell it as progress.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744198217a4562755.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信