Excel to image convertion - Chinese charset not correctly converted

Hi all,

I am using Aspose Cells .NET 5.2.2.5 to convert excel worksheets that contains charts to PNG image.
The problem is : Chinese charset is not correctly converted in the chart legend. See the horizontal axis of the second chart in the image attached.

Any ideas ?

You will find below the source code and attached the excel source file and the image generated.

Thanks for help,


This is the source code :
public string GenerateImageFromXls(string xlsPath, string sheetId, int horizontalResolution, int verticalResolution)
{
//Instantiate an instance of license and set the license file through its path
Aspose.Cells.License license = new Aspose.Cells.License();
license.SetLicense(ParametresConfiguration.AsposeCellsLicenseFilePath);
if (!string.IsNullOrEmpty(xlsPath))
{
Workbook book = new Workbook();
book.Open(xlsPath);
try
{
book.CalculateFormula(true);
}
catch
{
}
Worksheet sheet = book.Worksheets[sheetId];
//string maxCellName = GetMaxCellName(sheet);
//sheet.PageSetup.PrintArea = "A1:" + maxCellName;
sheet.PageSetup.SetFooter(0, string.Empty);
sheet.PageSetup.SetFooter(1, string.Empty);
sheet.PageSetup.SetFooter(2, string.Empty);
sheet.PageSetup.PaperSize = PaperSizeType.PaperCSheet;
sheet.PageSetup.CenterHorizontally = false;
sheet.PageSetup.CenterVertically = false;
sheet.PageSetup.LeftMargin = 0.0;
sheet.PageSetup.RightMargin = 0.0;
sheet.PageSetup.BottomMargin = 0.0;
sheet.PageSetup.TopMargin = 0.0;
sheet.PageSetup.FooterMargin = 0.0;
sheet.PageSetup.HeaderMargin = 0.0;
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
imgOptions.ImageFormat = ImageFormat.Png;
imgOptions.IsImageFitToPage = true;
imgOptions.HorizontalResolution = horizontalResolution;
imgOptions.VerticalResolution = verticalResolution;
imgOptions.OnePagePerSheet = true;
SheetRender sheetRender = new SheetRender(sheet, imgOptions);
string imagePath = xlsPath.Replace(".xls", string.Empty);
imagePath = string.Format("{0}_{1}.png", imagePath,
sheetId.Replace(" ", "_").Replace("&", "and").Replace("\\", "").Replace("/", "").Replace(":", "").Replace("*", "")
.Replace("\"", "").Replace("<", "").Replace(">", "").Replace("|", ""));
sheetRender.ToImage(0, imagePath);
return imagePath.Replace("\\", "/");
}
return null;
}

Hi,

Thanks for providing us the template file with sample code/details.

Please try Aspose.Cells for .NET v5.3.0.2, I have tested the conversion using your file with it and the output image is just fine, the Chinese char sets are converted fine in the labels.

Thank you.

Hi,


Thank you for your quick reply.
I have deployed the library v5.3.0.2 you provided (and of course uninstalled the previous version I had) but unfortunately I don’t have any improvement. The chinese characters are still displayed with small empty squares in the axis legend the same way in the attached image of the first post.

Hi,

Well, it works fine on my pc (I have Windows7 Ultimate OS, .NET Framework 3.5, 4.0). Find attached my output image, it is fine.

May be some fonts (regarding Chinese Charset) are not installed on your System/PC.

Thank you.