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

Free Support Forum - aspose.com

Wrong background color appears for tables and ranges

Hello,


I am using Aspose.Cells v8.6.3.6.

In case of tables and ranges, wrong background color appears when converting them to any format - Pdf, Image and Html. The issue appears for all these formats.

This is a break in v8.6.3.6. as compared to v8.6.3.

I have attached the Excel file, Html, PNG and PDF output, and Sample code used to generate the output in attachments.rar

Can you please analyse this issue.

Thanks,
Neha

Hi,


Thanks for the template file, sample code segments and generated files.

After an initial test, I observed the issue as you mentioned by using your template file with sample code segments you provided. I found that wrong background color appears for tables and ranges in the generated HTML/Image/PDF format(s).
e.g
Sample code:

String dynamicRange = “‘Sheet1’!B5:L15”;
String worksheetName = “Sheet1”;

Workbook workbook = new Workbook(“f:\files\wrong background color\background_color_issue.xlsx”);
Worksheet worksheet = workbook.getWorksheets().get(worksheetName);
// workbook.calculateFormula();
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\out1.html”, htmlSaveOptions);



Worksheet sheetForPDF = newWorkbook.getWorksheets().get(0);
sheetForPDF.getPageSetup().setTopMargin(0);
sheetForPDF.getPageSetup().setBottomMargin(0);
sheetForPDF.getPageSetup().setRightMargin(0);
sheetForPDF.getPageSetup().setLeftMargin(0);
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.setOnePagePerSheet(true);

Worksheet sheetForImage = newWorkbook.getWorksheets().get(0);
sheetForImage.getPageSetup().setTopMargin(0);
sheetForImage.getPageSetup().setBottomMargin(0);
sheetForImage.getPageSetup().setRightMargin(0);
sheetForImage.getPageSetup().setLeftMargin(0);
ImageOrPrintOptions imageOrPrintOptions = new ImageOrPrintOptions();
imageOrPrintOptions.setHorizontalResolution(600);
imageOrPrintOptions.setVerticalResolution(600);
imageOrPrintOptions.setOnePagePerSheet(true);
imageOrPrintOptions.setOnlyArea(true);
imageOrPrintOptions.setImageFormat(ImageFormat.getPng());
SheetRender sr = new SheetRender(sheetForImage, imageOrPrintOptions);
sr.toImage(0, “f:\files\out1.png”);


newWorkbook.save(“f:\files\out1.pdf”, pdfSaveOptions);

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

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

Thank you.
Hi,

This is to inform you that we have fixed your issue "CELLSJAVA-41698" now. We will soon provide the fix after performing QA and including other enhancements and fixes.

Thank you.

Hi,


Please download and try our latest version/fix: Aspose.Cells for Java v8.7.0

it should resolve your issue.

Let us know your feedback.

Thank you.