SheetRender.toImage() --Chinese charset not correctly converted

Hi,I am using Aspose Cells for Java 7.1.0 to convert excel worksheets to PNG(or jpeg) image. The problem is : Chinese charset is not correctly converted, The chinese characters are displayed with small empty squares.
It's ordinary when opened with MS Excel.

My OS is WindowsXP SP2.
===================================
This is my source code:
public class Excel2ImageTool {

/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
// Creating an Workbook object with an Excel file path
Workbook workbook = new Workbook("C:\\book1.xls");
int cnt = workbook.getWorksheets().getCount();
System.out.println("Page Count: " + String.valueOf(cnt));

// Create an object for ImageOptions
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
// Set the format type of the image
// imgOptions.setImageFormat(ImageFormat.getTiff());
// imgOptions.setTiffCompression(TiffCompression.COMPRESSION_CCITT_4);
imgOptions.setImageFormat(ImageFormat.getJpeg());
for (int i = 0; i < workbook.getWorksheets().getCount(); i++) {
// Get the worksheet.
Worksheet sheet = workbook.getWorksheets().get(i);

// Create a SheetRender object with respect to your desired sheet
SheetRender sr = new SheetRender(sheet, imgOptions);
for (int j = 0; j < sr.getPageCount(); j++) {
// Generate image(s) for the worksheet
sr.toImage(j, "C:\\images\\book1_sheet_" + i + "_page_" + j + ".jpg");
}
}
}

}

Hi,

Thanks for your posting and using the Aspose.Cells for Java.

Please download the latest version:

Aspose.Cells for Java 7.1.0

and replace the old aspose.cells jar file with the newer one: Aspose.Cells for Java v7.1.0.3

It seems the fonts used by your chinese characters cannot be found
automatically by our components. Please use
Cells.setFontDir()/setFontDirs()/setFontFiles() to specify the correct
font path so those characters can be rendered properly.

If the problem still does not resolve, then provide us your source xls/xlsx file.

Thank you for your reply.

After add a line code, the problem be resolved.
===============================================
This is my source code:
public static void main(String[] args) throws Exception {
// Creating an Workbook object with an Excel file path
Workbook workbook = new Workbook("C:\\book1.xls");
int cnt = workbook.getWorksheets().getCount();
System.out.println("Page Count: " + String.valueOf(cnt));

// Create an object for ImageOptions
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
// Set the format type of the image
imgOptions.setImageFormat(ImageFormat.getJpeg());

//**********Add this line************//
CellsHelper.setFontDir("c:\\windows\\fonts");

for (int i = 0; i < workbook.getWorksheets().getCount(); i++) {
// Get the worksheet.
Worksheet sheet = workbook.getWorksheets().get(i);

// Create a SheetRender object with respect to your desired sheet
SheetRender sr = new SheetRender(sheet, imgOptions);
for (int j = 0; j < sr.getPageCount(); j++) {
// Generate image(s) for the worksheet
sr.toImage(j, "C:\\images\\book1_sheet_" + i + "_page_" + j + ".jpg");
}
}
}

Hi,

It’s good to know, your problem is resolved now. Thanks for posting your sample code.

If you have any other questions, feel free to post here. We will help you asap.