Images converted from an excel cell range containing Cell Styles do not have those Cell Styles applied

Hi there - we’re trialling aspose and have been happy so far with it’s functionality. However, one issue that we’re seeing is that when we try to convert images from an excel range that contains Cell Styles applied, we’re not seeing those cells styles in the resulting images. See the example below:

Cell range in excel w/ Cell Styles:
image.jpg (445.4 KB)

Resulting Image from Aspose:
image.png (199.2 KB)

As you can see - all of the Cell Styles are lost, from the green border at the top, to the font colours. Can you kindly let us know how we can ensure that the Cell Styles are applied correctly?

Thanks!

@crussell.vena
Could you show a sample project with sample file ? We will check it soon.
And Which version are you using ?

@simon.zhao - Thanks for the quick reply! We’re using Aspose.cells for Java - Version 23.2

Here is a sample of the code:


package groupid;
import com.aspose.cells.*;

/**

  • Aspose Cells API Test

*/
public class App
{
private static void generateImage(String absoluteFileName, String outDir) throws Exception {

// Create workbook from source file.
Workbook workbook = new Workbook(absoluteFileName);

// Access the second worksheet Summary
Worksheet worksheet = workbook.getWorksheets().get(1);

// Set the print area with your desired range
worksheet.getPageSetup().setPrintArea(“E4:AE41”);

// Set all margins as 0
worksheet.getPageSetup().setLeftMargin(0);
worksheet.getPageSetup().setRightMargin(0);
worksheet.getPageSetup().setTopMargin(0);
worksheet.getPageSetup().setBottomMargin(0);

// Set OnePagePerSheet option as true
ImageOrPrintOptions options = new ImageOrPrintOptions();
options.setOnePagePerSheet(true);
options.setHorizontalResolution(400);
options.setVerticalResolution(400);
options.setImageType(ImageType.PNG);

// Take the image of your Table range
SheetRender sr = new SheetRender(worksheet, options);
sr.toImage(0, outDir + “AsposeSummaryTest.png”);

}

public static void main(String[] args) throws Exception{
    com.aspose.cells.License license = new com.aspose.cells.License();
    license.setLicense("Aspose.Cells.Java.lic");

    String absoluteFileName = "//Users//rbansal@venacorp.com//CapexSummary.xlsx";
    String outDir = "//Users//rbansal@venacorp.com//";
    generateImage(absoluteFileName, outDir);
}

}


Thanks again!

@crussell.vena,

Thanks for further details and sample code segment.

We also require your template Excel file to evaluate your issue precisely. So, kindly zip your input Excel file and attach it here, we will check it soon.

By the way, one possibility of losing cell formatting is due to “Black and white” option set in Page Setup|Sheet tab, see the screenshot attached for your reference.
sc_shot1.png (48.0 KB)

Please note, if this option is enabled in the Page Setup dialog for the worksheet, all color shading aspects for foreground/background, borders and fonts would be discarded and it will be rendered to black/white only. So, you need to disable this option (if enabled).

Wow - the black and white option was selected… This resolved the issue! Thanks so much for the help.

@crussell.vena,

Good to know that after disabling the mentioned option, it figures out your issue. Feel free to write us back if you have further queries or comments, we will be happy to assist you soon.