Width from HTML tag is not honoured


I am generating a workbook from HTML. The width attribute in the HTML is not considered in the workbook created.

I have attached the snip of my code.

HTMLLoadOptions loadOptions = new HTMLLoadOptions(LoadFormat.Html);
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(htmlData)))
Workbook wb = new Workbook(stream, loadOptions);
var sheet = wb.Worksheets[0];
using (var documentStream = new MemoryStream())
wb.Save(documentStream, SaveFormat.Xlsx);

Amith Antony



Please share the source HTML file for our analysis here. Also please provide some snapshot showing the issue if possible.


I have attached the HTML I use also the excel generated. When the HTML is viewed in browser the table columns are with the given width. But in excel the column width is ignored.

Table width.zip (26.4 KB)



We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-46219 - Width from HTML tag is not followed while converting HTML to XLSX



Please try to set auto-fit rows and columns on while loading the HTML file, it will work better as I tested:
Sample code:

        HTMLLoadOptions opts = new HTMLLoadOptions(LoadFormat.Html);

opts.AutoFitColsAndRows = true;
Workbook workbook = new Workbook(“e:\test2\Table Width Sample.html”, opts);
string output = “e:\test2\out1.xlsx”;

Let us know if you still find the issue.


Thank you @Amjad_Sahi

Your solution works perfectly for my case. Once again thank you so much.



Good to know that your issue is sorted out by the suggested line(s) of code. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.


Hi @Amjad_Sahi,
I face one more issue in the same xslx generation. The multiline text is displayed as a single line.

image.png (14.0 KB)
image.png (12.8 KB)

I use the same HTML to generate PDF document and it works fine.



Thanks for the screenshots.

Well, I noticed this but we think it is a minor thing as setting HTMLLoadOptions.AutoFitColsAndRows attribute to true might not mimic 100% with your original HTML file, so you have to live with it.