We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Excel to html content has some non-closing html tags

I was trying to create excel workbook to html file. It does create and work well while opening in browser. But found that in html code some of the html tags doesn’t have proper closing tags like the following
tags (link, meta, col tags) (pasted below). Attached the html file which is generated using aspose.

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="ProgId" content="Excel.Sheet">
<meta name="Generator" content="Aspose.Cell 20.6.0">
<link rel="File-List" href="/filelist.xml">
<link rel="Edit-Time-Data" href="/editdata.mso">
<link rel="OLE-Object-Data" href="/oledata.mso">

We use this html to do further conversion to other formats during which it fails as this html doesn’t have closing tags for these. Is there a way to generate these tags with closing tags like
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

Here is the code used to convert excel workbook to html

public byte[] convertToHtml(Workbook wb) throws Exception {
HtmlSaveOptions opts = new HtmlSaveOptions();
ByteArrayOutputStream os = new ByteArrayOutputStream();
wb.save(os, opts);
///wb.save(destinationHtmlFile, opts);
return os.toByteArray();

MainReport_Template.html.zip (12.3 KB)


Thanks for the sample file and code segment.

Please note, Aspose.Cells follows MS Excel standards and specifications when parsing or rendering to HTML file format. I can see these meta heading tags are there (without closing tags) when you manually convert an Excel file to HTML (“Web Page”) in MS Excel manually. Aspose.Cells just follows MS Excel standards and cannot go beyond it, so these heading tags will be retained as they are.

Atleast is there a way to put the styles under rather than inside

If you notice currently the following style is generated within <body> tag. Can it be created within <head> tag

<style>.x118 { vertical-align: middle; white-space: nowrap; background-color: initial; background-image: initial; font-size: 10pt; font-weight: 400; font-style: normal; font-family: "Arial", "sans-serif"; }</style>


Please provide input Excel file and output HTML file(s) generated by Aspose.Cells for evaluation. You may zip the files and attach it here, we will check it soon.

MainReport_Template.xlsx.zip (30.6 KB)


I tested your scenario/ case using your file to convert to HTML with the following sample code using latest version/fix: Aspose.Cells for Java v20.6.x, it works fine. I can see all styles/formattings (e.g style0 upto .x118) are declared in <head> tag. However, I noticed .x119 is pasted in the end although it is outside of <body> section, so it is ok:
Sample code:

Workbook workBook = new Workbook("f:\\files\\MainReport_Template.xlsx");
		HtmlSaveOptions opts = new HtmlSaveOptions();
		workBook.save("f:\\files\\outMainReport_Template1.html", opts);

Please find attached the output HTML file for your reference.
files1.zip (12.2 KB)

Question is why is .x119 alone is coming outside of head tag at the end? I would want to have all styles inside head tag. Since .x119 is not within head tag and its within html tag, it does causes issue while rendering later using some other tool

We have observed this issue where one of the style is found outside the head tag. This issue is logged in our database for an investigation and fix (if possible).

This issue is logged as:
CELLSJAVA-43242 -One of the style tag found outside the head tag

Just to add to it, that style is used for the image tag.
Attached zip has excel and html for reference as the previous one doesn’t have the right style

share.zip (42.6 KB)

We have tested the new file and observed the issue in it as well. It is logged with ticket for our reference.

This is to inform you that we have fixed your issue (logged earlier as “CELLSJAVA-43242”) now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.


Please try the attached version/fix.
aspose-cells-20.7.2-java.zip (7.1 MB)

Let us know your feedback.


The issues you have found earlier (filed as CELLSJAVA-43242) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

A post was split to a new topic: Excel to HTML - cols are getting generated in html under the main table tag