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

@sunithaprabhu,

Please wait while we figure out the issue (logged earlier as “CELLSJAVA-43180”) , so you do not have to use any workaround.

If you still persist with the workaround, you may try the updated code segment:
e.g
Sample code:

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.setForegroundColor(Color.getWhite());
style.setPattern(BackgroundType.SOLID);
wb.getWorksheets().get(0).getCells().setStyle(style);
ByteArrayOutputStream excelOut = new ByteArrayOutputStream();
wb.save(excelOut, new SpreadsheetML2003SaveOptions(SaveFormat.XLSX));

Your code is not working either… Can you try on the html file I provided? Wondering why is that simple style setting is not working.

@sunithaprabhu,

As I said, let us evaluate the issue first (please spare us time) and then hopefully your issue will be sorted out by some fix and you do not need to go for any workaround.

I will wait for the issue to be fixed… But question is not about the fix… You may think of this as a different question… why is the styles not working generally with excel

@sunithaprabhu,
Thank you for sharing your thoughts. Please spare us time to identify and then rectify the issue. We will try to provide you more details about the issue if and when possible.

The issues you have found earlier (filed as CELLSJAVA-43164) have been fixed in Aspose.Cells for Java v20.5. This message was posted using Bugs notification tool by ahsaniqbalsidiqui

Can you elaborate on which issue has been fixed?

I see the sheet fully black color issue has been fixed but couple of issues are still there.

  1. The background color style is not being retained during html to excel conversion. If you see the table header has grey background in html but in excel that is lost.
  2. Setting the grid lines was working in earlier version but now grids are not showing up in excel.

Attached the html and excel for your reference and here is the code for conversion

  HtmlLoadOptions opts = new HtmlLoadOptions();
    opts.setAutoFitColsAndRows(true);
    //Create workbook from your HTML string
    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(excelOut, new SpreadsheetML2003SaveOptions(SaveFormat.XLSX));
    return excelOut.toByteArray();

Archive.zip (9.9 KB)

@sunithaprabhu,
We have observed the issues mentioned above and will analyze them soon for providing our feedback. Regarding the resolved issue we have resolved following issues, however we will share more information after discussion here.

Html to Excel conversion not retaining the rich text formats in the output
Html to Excel conversion creating black worksheet output

@sunithaprabhu,

This is to inform you that we have fixed your issues (“CELLSJAVA-43180” and “CELLSJAVA-43181”) and hopefully you will be getting the fix in the next few days after we have performed QA and incorporated other enhancements and fixes.

@sunithaprabhu,

Please try our latest version/fix: Aspose.Cells for Java v20.5.1 (attached)
aspose-cells-20.5.1-java.zip (7.1 MB)

Your issues should be fixed in it.

Let us know your feedback.

Thanks for the quick turnaround. Tested it. It does fix the actual excel being complete black issue and the row height issue but has the following 2 issues ( stated the same in my previous message)

  1. The background color style is not being retained during html to excel conversion. If you see the table header has grey background in html but in excel that is lost.
  2. Setting the grid lines was working in earlier version but now grids are not showing up in excel.

@sunithaprabhu,

Please make sure that you are using Aspose.Cells for Java v20.5.1. I tested using the following sample code with Aspose.Cells for Java v20.5.1 and it works fine and I do not find these issues:
e.g
Sample code:

HtmlLoadOptions opts = new HtmlLoadOptions();
	    opts.setAutoFitColsAndRows(true);
	    //Create workbook from your HTML string
	    Workbook wb = new Workbook("f:\\files\\report.html", opts);
	    wb.getWorksheets().get(0).setGridlinesVisible(true);
	    //Save the workbook in output format
	    wb.save("f:\\files\\out1.xlsx", SaveFormat.XLSX);

I have also attached the output file for your reference.
files1.zip (7.2 KB)

Hi Thanks for the fixes. It works now. I appreciate your effort in getting the fixes quickly. I do not see the same from the pdf/html product line where I had raised couple of issues but never got any fixes. Is there anyway we can get the fixes for these Html/PDG issues.

  • HTMLJAVA-388 - Data doesn’t fit inside table and image coming at bottom
  • HTMLJAVA-401 - Html to pdf conversion not generating more than 4 pages

@sunithaprabhu,

Good to know that your issues regarding Aspose.Cells are fixed in the new fix.

I am afraid, I can only help you for technical queries and issues regarding Aspose.Cells here. I have intimated respective team and they will update you in your threads soon. Please follow up your relevant threads in respective forums to get latest updates and get these issues fixed soon.

The issues you have found earlier (filed as CELLSJAVA-43180,CELLSJAVA-43181) have been fixed in Aspose.Cells for Java v20.6. This message was posted using Bugs notification tool by ahsaniqbalsidiqui