Html to excel - css style ignored for column widths- row heights- word wrap- and more

We are evaluating the Cells product for use within a web application. Our goal is to convert an html table report, with CSS styles in the page, to an Excel document (xlsx). The converter works for the most part, however, the word wrap, heights, widths, and other things are ignored with the converter. Is this intended, or a bug? I have attached the sample html file that is being converted, along with the excel output. Additionally, the PDF output chops off sentences instead of obeying the word wrap style in the CSS. If I simply drag the html test file over to Excel, Excel opens the html and applies the CSS styling correctly. Is there a setting I am missing? We are using Visual Studio 13 with Nuget and the installed package is 9.0.0.

Here is the code:

Aspose.Cells.HTMLLoadOptions options = new Aspose.Cells.HTMLLoadOptions(Aspose.Cells.LoadFormat.Html);
Aspose.Cells.Workbook book = new Aspose.Cells.Workbook(fileNameHtml, options);
book.Worksheets[0].Cells.StandardWidthPixels = 90;
book.Save(fileNameHtml + “.xlsx”, Aspose.Cells.SaveFormat.Xlsx);
book.Save(fileNameHtml + “.pdf”, Aspose.Cells.SaveFormat.Pdf);
Any thoughts?

Hi,


Thanks for providing us template file, sample code and details.

After an initial test, I observed the issue as you mentioned by using your sample code with your template file. I found that CSS style ignored for column widths, row heights and word wrap, etc. in HTML to Excel rendering.
e.g
Sample code:

Aspose.Cells.HTMLLoadOptions options = new Aspose.Cells.HTMLLoadOptions(Aspose.Cells.LoadFormat.Html);
Aspose.Cells.Workbook book = new Aspose.Cells.Workbook(fileNameHtml, options);
book.Worksheets[0].Cells.StandardWidthPixels = 90;
book.Save(fileNameHtml + “.xlsx”, Aspose.Cells.SaveFormat.Xlsx);
book.Save(fileNameHtml + “.pdf”, Aspose.Cells.SaveFormat.Pdf);

I have logged a ticket with an id “CELLSNET-44790” for your issue. We will look into your issue soon.

Once we have an update on it, we will let you know here.

Thank you.
Hi,

Thanks for using Aspose.Cells.

This is to inform you that we are working over this issue and hopefully, we will be able to fix it before October 18, 2016. Once, the fix is available for you, we will provide a download link at this thread for your testing.

Hi again,


This is to update you that we have resolved the problem logged earlier as CELLSNET-44790. We will shortly share the fix here after ensuring the quality and incorporating other enhancements.
Hi,

Thanks for using Aspose.Cells.

Please download and try the latest fix: Aspose.Cells for .NET v16.10.1.0 and let us know your feedback.

The widths, heights, and some word wrapping are fixed now. However, there are still some issues:

1) Word-wrap is still not working when a cell is merged across columns. It seems to work fine for single cells. It works fine for single columns merged across rows.
2) New lines within a cell (e.g.
) are not working. The text after the
is ignored. Also, if
appears in the html as
, then the text after is showing up in a different cell. Also tried
and it was ignored as well.
3) CSS styles for min-width and max-width are still ignored.
4) Saving to PDF still ignores cell word wrapping for single cells (the row height is not being adjusted for the header columns).

I have attached a zip containing the problematic htm file and excel/pdf outputs. Note that dragging the htm file over to Excel works fine.

Thanks for resolving the other issues so quickly.

Anthony
The Analytical Group, Inc

Hi,


Thanks for your posting and using Aspose.Cells.

We were able to observe column width issue and found that when html file is opened in excel, it has different column widths than when it is generated with Aspose.Cells. However, in order to fix all of your issues, please provide a MS-Word document, which should contain screenshots highlighting your issues in red circles. This will enable us to fix all of your issues and if we need to create separate tickets for each of them, we will create it. Thanks for your cooperation in this regard and have a good day.

please provide a MS-Word document, which should contain screenshots highlighting your issues in red circles

Thank you for taking a look, however, I think you have everything that you need, even if it is not in the format you use internally. You have the HTML with the CSS. You should be able to determine how it should work, based on the standards available on the internet. :slight_smile:

We appreciate your efforts in fixing some of the initial bugs for our trial testing, and wish you well with your product. We will be going with other options that are more complete for our purposes. Thank you for your time.

Regards,
Anthony

Hi,


Thanks for your posting and using Aspose.Cells.

We were able to observe this issue and logged it in our database for investigation. We will look into it and fix the issue. Once the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as

  • CELLSNET-44829 - Output HTML does not match with Microsoft Excel

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


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

@AnthonyFromAnalytica

Please download and try the following fix and let us know your feedback


Please see the following sample code for your issue CELLSNET-44829.

C#

HTMLLoadOptions options = new HTMLLoadOptions();
options.AutoFitColsAndRows = true;

Workbook wb = new Workbook(filePath + "TestHTML.htm", options);
wb.Save(filePath + "out.xlsx");

The issues you have found earlier (filed as CELLSNET-44829) have been fixed in this Aspose.Cells for .NET 18.2 update.

Please also check the following article:

I am using Aspose.Cells 19.8, still I am facing issues with columns width and row height issues.
As mentioned above, I tried by downgrading version to 16.8 but still no luck. also tried with latest stable release i.e. 19.11.0

Code snippet:
string postData = await Request.Content.ReadAsStringAsync();
MemoryStream inputStream = new MemoryStream(Encoding.UTF8.GetBytes(postData));
Aspose.Cells.HtmlLoadOptions options = new Aspose.Cells.HtmlLoadOptions(Aspose.Cells.LoadFormat.Html);
options.AutoFitColsAndRows = true;
options.AutoFitterOptions = new AutoFitterOptions
{
AutoFitMergedCellsType = AutoFitMergedCellsType.EachLine
};
options.SetPaperSize(PaperSizeType.PaperA4);

            Workbook workbook = new Workbook(inputStream, options);
            workbook.Save(@"C:/abc.xls", Aspose.Cells.SaveFormat.Excel97To2003);

FYI : I’m using .net framework 4.6.1
Request you to help here.

Thanks in advance…

@SutarM,

Thanks for the sample code segment and details.

Please provide your template HTML file, so we could evaluate your issue precisely using your sample code segment. You may zip the HTML file prior attaching here.

@SutarM
This query is replied here. Please refer to it for more updates on it.