Create Workbook from HTML and get Cells in range cannot be merged because cells in range have already been merged

Hi Aspose Team,

I get this exception while performing load HTML to Workbook.

Pseudocode below -

byte[] byteArray = Encoding.UTF8.GetBytes(html);

using (MemoryStream stream = new MemoryStream(byteArray))

{

return new Workbook(stream);

}


Normally these code working fine and we got excellent excel file. but sometime when we do some large and complicate HTML . we got the exception like this

Cells in range K5:L5 cannot be merged because cells in range K4:L5 have already been merged.

we think you can reproduce this problem using attach file.


I am not sure is there a merge problem inside the HTML . but even it is a problem .

I still need a way to bypass those error and let user get an Excel file (we don't need perfect Excel)


right now , we can only show these error message to our client , but we don't know how to explain to them that their HTML have problem to convert to EXCEL.

Could you please advice whether we have any workaround?

Thanks!

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

We were able to replicate this exception with your given html file. We have logged this issue in our database for investigation. We will look into it and resolve this 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-42105.

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


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

Hello, having the exactly same error using Aspose Cells for Java! @shakeel.faiz

@sZiu
Could you post your template html file here? We will check it soon.

output.zip (283.2 KB)

@sZiu,

Your zipped archive is damaged, so I could not extract the file(s) from it. Please re-zip the archive properly and attach it, we will check it soon.

output.zip (459.8 KB)

@sZiu,

We reproduced the issue as you mentioned by loading your template HTML file. We found an exception “com.aspose.cells.CellsException: Cells in range A23:R23 cannot be merged because cells in range A23:A24 have already been merged” on reading the HTML.
e.g.
Sample code:

Path path = Paths.get("f:\\files\\output.html");
byte[] byteArray = Files.readAllBytes(path);
InputStream inputStream = new ByteArrayInputStream(byteArray);
HtmlLoadOptions loadOptions = new HtmlLoadOptions(LoadFormat.HTML);
Workbook convertedDocument = new Workbook(inputStream, loadOptions);//exception

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSJAVA-45097

You can obtain Paid Support services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@sZiu
We have fixed the issue of throwinig exception, but there are still some layout issues when importing your template html file.

you can fix them as well…?

@sZiu,

Yes, sure, we will also fix these issues. Once we resolve them, we will update you again.

1 Like

Thank you very much!

@sZiu,

You are welcome.

@ghostofisland
The file contains many tables with different column widths, but each sheet of an Excel file can only have one table, and the column widths must be uniform.
We can only do as much as possible as shown in Excel. But we need some time to study a better layout.

@ghostofisland
Please check23.2.1.zip (291.1 KB)
generenated by inner hot fix 23.2.1.
There are still some issues .
Could you share your source template words file?
“float:left” css applies to some images,so some images and tables are horizonally aligned in brower.
But we need more time to study how to make “float:left” css works in Excel files.