Excel to HTML - how cols are getting generated in html under the main table tag

Thanks a lot.

When I convert excel to html I see that col are getting generated in html under the main table tag. May I know how are the widths of the col are manipulated? Moreover the style .X17 is generated with nowrap property, wondering how was that property captured from excel.

    <table border='0' cellpadding='0' cellspacing='0' width='638' style='border-collapse: 
 <col class='x16' style='mso-width-source:userset;background:none;width:31.35%'>
 <col class='x106' style='mso-width-source:userset;background:none;width:23.67%'>
 <col class='x16' span='2' style='mso-width-source:userset;background:none;width:14.26%'>
 <col class='x16' style='mso-width-source:userset;background:none;width:16.46%'>

Attached the excel and html output for your reference. I see that some of the data in first column are bigger and so chopped off and so trying to see if I can increase the width

Archive.zip (44.6 KB)


This is not an issue with Aspose.Cells by any means. Aspose.Cells follows Ms Excel standards and specifications when rendering to HTML file format. You may manually save the file to “Web Page” in Ms Excel and check the source of the generated HTML. You will notice almost the same source code as per Aspose.Cells for its generated HTML. You will see the style .X17 is documented with nowrap attribute as well.


I also see the first column does not display the content fully in the html generated by MS Excel as well, so it is also not an issue. To extend the column’s width you may either apply auto-fit column operation or extent the column’s width a bit in code for your requirements. See the sample code that I tried and it works ok:
Sample code:

Workbook workBook = new Workbook("f:\\files\\MainReport_Template.xlsx");
		Worksheet worksheet = workBook.getWorksheets().get(0);
		//auto-fit the first column to display complete data in the column cells.
		//Or extend the column width.
		//worksheet.getCells().setColumnWidth(0,  300);
		HtmlSaveOptions opts = new HtmlSaveOptions();
		workBook.save("f:\\files\\outMainReport_Template1.html", opts);

Thanks… but unfortunately this solution will not work as this will cross the border if the data is huge… instead I went. with wrapping approach… but can you answer how the no-wrap property for td got generated in html from excel?


I am afraid, there is no better way to cope with it as I could not spot it. If you still think in MS Excel you can accomplish your desired output in some automatic way using some featured MS Excel option(s) while rendering to HTML, let us know with details (steps involved) and sample output file, we will check on how to do it via Aspose.Cells APIs.

As I told you we follow MS Excel standards and specifications when parsing and rendering HTML, so you may save the Excel file to “Web page” manually and you will notice almost the same source with the no-wrap property for those td(s). If you spot something significantly different, kindly provide details and some screenshots for the source of HTMLs (by Ms Excel and Aspose.Cells), we will check it soon.