Html to Excel conversion (in java) not retaining the richtext formats in excel output

Tried the exact code for having grid on, did not work

Regarding converting html to doc, I had used the exact code which you mentioned (as per my previous comment), it did not work and I have attached the files as well (in my previous comment). If you can check those files to see why it didn’t work that would be good.

@sunithaprabhu,
Regarding the issue of converting your latest HTML sample file to docx, you may please post this query on Aspose.Words forum along with sample files and code used for testing.

For the grid issue, I can see the grids in the print preview of the Excel file as attached here. Please have a look at the attached output file and snapshot for your reference.

Test2.zip (7.9 KB)
Capture.PNG (9.9 KB)

@sunithaprabhu,

Please use the following line of code instead:

wb.getWorksheets().get(0).setGridlinesVisible(true);

it will work for your needs.

Great. This one worked. Thanks a lot. I posted my other question in Aspose word forum. Hope someone will response. Thanks for your quick response. Appreciate it.

@sunithaprabhu,

Good to know it is sorted out by the suggested line of code.

@sunithaprabhu,

Please try our latest version/fix: Aspose.Cells for Java v20.4.3 (attached)

Your issue should be fixed in it.

Let us know your feedback.
aspose-cells-20.4.3-java.zip (7.0 MB)

CAn you explain what fix does it contain?

@sunithaprabhu,
This ticket was logged as follows:
Html to Excel conversion not retaining the rich text formats in the output

You may please check the rich text formatting like for TL_summary_orig.html. Please compare the results and provide your feedback.

Thanks a lot. The fix works.Appreciate it

A post was split to a new topic: HTML to PDF conversion help

How do I insert a cell at a particular row and col? I see the api in Cells for inserting row or inserting column but not for inserting a cell.

@sunithaprabhu,
You can insert cells with InsertRange Method. Please try below codes and let us know your feedback.

Workbook workbook = new Workbook("D:\\Insert.xlsx");
Worksheet worksheet = workbook.Worksheets[0];
CellArea area;
area.StartRow = 1;
area.EndRow = 2;
area.StartColumn = 2;
area.EndColumn = 3;
worksheet.Cells.InsertRange(area, ShiftType.Down);
workbook.Save("D:\\InsertCells.xlsx");

Hi

I am trying to convert the excel to html and again back to excel. like Excel -> Html - > Excel. All conversions are done using aspose libraries The output excel has couple of issues

  1. It was failing during conversion from html to excel as one of the row height was > 409. This input html itself was generated from aspose library. I did see one of the row height was > 800 which I manually corrected it. But need to know why the excel to html conversion has this bigger row height.
  2. After manully editing the row height to lower value and trie converting it to Excel. Excel file is completely black

Following is the code to convert from html to excel

    HtmlLoadOptions opts = new HtmlLoadOptions();
    opts.setAutoFitColsAndRows(true);
    Workbook wb = new Workbook(new ByteArrayInputStream(htmlFile), opts);
    wb.getWorksheets().get(0).setGridlinesVisible(true);
    //Save the workbook in output format
    ByteArrayOutputStream excelOut = new ByteArrayOutputStream();
    wb.save("/TL_Report1.xlsx");

Attached the initial excel and the intermediate html (report.html) and final excel (TL_Report1.xlsx). Can you please check and let me know. This is bit urgent, if anyone can look at it quickly would help. We are still in the process of license renewal. Once renewed will use paid support. Until then expecting help.

Archive.zip (24.3 KB)

@sunithaprabhu,
Regarding your first issue could please share the template file, sample code and program output for our reference.

For the second issue we were able to observe the issue with the following sample code 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.

 HtmlLoadOptions opts = new HtmlLoadOptions();
opts.setAutoFitColsAndRows(true);
Workbook wb = new Workbook("report.html", opts);
wb.getWorksheets().get(0).setGridlinesVisible(true);
wb.save("TL_Report2.xlsx");

This issue has been logged as

CELLSJAVA-43180 – Html to Excel conversion creating black worksheet output

Regarding the first issue, the input.xlsx I shared previously was the excel that was converted to report1.html (attached). If you notice this report1.html has a row with height ‘816’ which was causing issue (with error ‘row height should be < 409’) while converting this html back to excel. So we need to find out why is this html conversion creates a row with this height from the input.xlsx.

-Sunithareport1.html.zip (2.7 KB)

Would I be able to get some kind of workaround (for the issue 2) until we get the fix so that we may proceed? This is kind of blocking issue now.

@sunithaprabhu,
We were able to observe the first issue as well 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

CELLSJAVA-43181 - Difference in row height in converting Excel to Html

As we just logged the ticket, so could you spare us a little time (3-5 days or so) for complete evaluation and investigation for your issues.

Thanks. The issue title shows as covnerting Html to Excel. I see the problem is with first conversion which is excel to html conversion. If you notice the html file has a row of height 816 which must be coming during excel to html conversion.

By the way where can I track these issues? Where is your issue tracker?

@sunithaprabhu,
Thank you for pointing it out and it is corrected in the ticket title. All the details are already shared in the ticket as stated by you. Regarding the issue tracking, the ticket status is shown here on the thread and we write immediately whenever any update is required to be shared. We will keep you updated here about the progress.

I am trying to resolve the black background issue (2) by changing the background as below… but it’s not taking effect though

Workbook wb = new Workbook(new ByteArrayInputStream(htmlFile), opts);
wb.getWorksheets().get(0).setGridlinesVisible(true);
//setting background color to white as it becomes black now
Style style = wb.getWorksheets().get(0).getCells().getStyle();
style.setBackgroundColor(Color.getWhite());
wb.getWorksheets().get(0).getCells().setStyle(style);
ByteArrayOutputStream excelOut = new ByteArrayOutputStream();
wb.save(excelOut, new SpreadsheetML2003SaveOptions(SaveFormat.XLSX));

Any idea why style not working?