We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Wrong background-color for cells appears when exporting a range of cells to html

Hello,


I am using Aspose.Cells v8.6.2

I am converting the range - ‘Projects’!B4:E19 in the attached excel file (refer - test.xslx) to html. The actual background-color of range C4:E4 is : #D9F3D3 (light green), but when I generate the html using aspose, it gives wrong background-color. The background-color of range C4:E4 in Aspose-generated html is : #DCE6F2 (gray).

I am using the following sample code to generate the html:

void dynamicRangeToHtml() throws Exception {

String dynamicRange = “‘Projects’!B4:E19”;
String worksheetName = “Projects”;
Workbook workbook = new Workbook(“D:\test.xlsx”);
Worksheet worksheet = workbook.getWorksheets().get(worksheetName);
int rangeIndex = workbook.getWorksheets().getNames().add(“dummyrange”);
Name name = workbook.getWorksheets().getNames().get(rangeIndex);
name.setRefersTo(dynamicRange );
name = workbook.getWorksheets().getNames().get(rangeIndex);
Range sourceRange = name.getRange();

Workbook newWorkbook = new Workbook(FileFormatType.XLSX);
WorksheetCollection targetWsc = newWorkbook.getWorksheets();
Worksheet targetWs = (Worksheet)targetWsc.get(0);
Range targetRange = targetWs.getCells().createRange(0, 0, sourceRange.getRowCount(), sourceRange.getColumnCount());
PasteOptions options = new PasteOptions();
//Copy column widths
options.setPasteType(PasteType.COLUMN_WIDTHS);
targetRange.copy(sourceRange, options);

// Copy row heights
int rowCount = sourceRange.getRowCount();
int firstRow = sourceRange.getFirstRow();

for (int i = 0; i < rowCount; i++) {
double rowHeight = sourceRange.getWorksheet().getCells().getRowHeight(firstRow++);
targetWs.getCells().setRowHeight(i, rowHeight);
}
//Copy everything else
options.setPasteType(PasteType.ALL);
targetRange.copy(sourceRange, options);

HtmlSaveOptions htmlSaveOptions = new HtmlSaveOptions(SaveFormat.HTML);
htmlSaveOptions.setHiddenColDisplayType(1);
htmlSaveOptions.setHiddenRowDisplayType(1);
htmlSaveOptions.setParseHtmlTagInCell(true);

newWorkbook.save(“D:\Aspose-generated-html.html”, htmlSaveOptions);
}

I have attached the screenshots of Aspose-generated html and Excel-generated html.

Can you please look into this issue.

Hi Neha,

Thanks for your sample code and using Aspose.Cells.

We were able to replicate this issue by executing your sample code with the latest version: Aspose.Cells
for Java v8.6.2.1
and found that background color of cell gets changed. However, when we simply save your excel file into html, the issue does not occur, so the issue might be specific to your code.

We have therefore logged this issue in our database for investigation. We will look into it and fix 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

  • CELLSJAVA-41603 - Wrong background-color for cells appears when exporting a range of cells to html.

Thanks for your response.

This issue is critical for us as its a production issue being faced by one of our customers.

Can you please look into this on priority and let me know when could we get the fix for this?

Thanks,
Neha

Hi,

Thanks for your posting and using Aspose.Cells.

Mostly such issues are fixed in less than two weeks. So please spare us that much time. We are hopeful your issue will be fixed in this time span. Once the fix is available for you, we will let you know about it by posting in this thread.

Hello,

Is there any update on this issue?

This is a very critical issue for us as its a production issue being faced by one of our customers and they are asking us for an immediate fix.

Can you please look into this on urgent basis and let me know when could we get the fix for this?

Thanks,
Neha

Hi Neha,

Thanks for your posting and using Aspose.Cells.

We are afraid, your issue is still unresolved. However, we have logged your comment in our database against this issue for product team consideration. Hopefully, your issue will be fixed soon or we will be able to provide you some ETA. Once there is some news for you, we will update you asap.

Hi Neha,

Thanks for using Aspose.Cells.

We have looked into this issue further and found that this is not a bug. If you copy cells B4:E4 to some new Excel workbook, its color changes to blue.

It happens because the style collection doesn’t copy together. If you copy Workbook, it will be ok.

Hi,


Could you please try our latest fix/version: Aspose.Cells for Java v8.6.3.2
Your issue should be fixed in it.
Let us know your feedback.

Thank you.

Hello,


Thanks for your reply.

I tried your latest fix Aspose.Cells v8.6.3.2 to test this issue. Unfortunately, the issue still exists. In the HTML output, grey color appears while in actual chart the color is green. I have attached the Excel generated Html and the Html generated using Aspose.Cells v8.6.3.2 in txt format (unable to attach in html format).

This is a critical issue for us as it is reported by one of our customers.

Can you please look into this on priority.

Thanks,
Neha

Hi,


I have tested your scenario/ case using our latest version/fix: Aspose.Cells for Java v8.6.3.4, it works fine and I do not find your mentioned issue. Please find attached the zipped archive that contains the output Html and resource files.
I used the following sample code with your template file.
e.g
Sample code:

String dynamicRange = “‘Projects’!B4:E19”;
String worksheetName = “Projects”;
Workbook workbook = new Workbook(“test.xlsx”);
Worksheet worksheet = workbook.getWorksheets().get(worksheetName);
int rangeIndex = workbook.getWorksheets().getNames().add(“dummyrange”);
Name name = workbook.getWorksheets().getNames().get(rangeIndex); name.setRefersTo(dynamicRange );
name = workbook.getWorksheets().getNames().get(rangeIndex);
Range sourceRange = name.getRange();

Workbook newWorkbook = new Workbook(FileFormatType.XLSX);
WorksheetCollection targetWsc = newWorkbook.getWorksheets();
Worksheet targetWs = (Worksheet)targetWsc.get(0);
Range targetRange = targetWs.getCells().createRange(0, 0, sourceRange.getRowCount(), sourceRange.getColumnCount());
PasteOptions options = new PasteOptions();
//Copy column widths
options.setPasteType(PasteType.COLUMN_WIDTHS);
targetRange.copy(sourceRange, options);

// Copy row heights
int rowCount = sourceRange.getRowCount();
int firstRow = sourceRange.getFirstRow();

for (int i = 0; i < rowCount; i++) {
double rowHeight = sourceRange.getWorksheet().getCells().getRowHeight(firstRow++);
targetWs.getCells().setRowHeight(i, rowHeight);
}
//Copy everything else
options.setPasteType(PasteType.ALL);
targetRange.copy(sourceRange, options);

HtmlSaveOptions htmlSaveOptions = new HtmlSaveOptions(SaveFormat.HTML);
htmlSaveOptions.setHiddenColDisplayType(1);
htmlSaveOptions.setHiddenRowDisplayType(1);
htmlSaveOptions.setParseHtmlTagInCell(true);

newWorkbook.save(“f:\files\out1Aspose-generated-html1.html”, htmlSaveOptions);



Thank you.


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


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