Hi ,
We are trying to copy a chart from one excel to another but the charts are not get renedered well. Also we tried to convert a whole excel sheet to image, and still the charts are not rendered well in the destination image file. Could you help with this and get us any method where we could render charts well as either image or as charts(with same appearance as source) on the destination excel. This is very critical for us to complete our project.
Please find below the code samples and PDF and image file attachements.
1) convert an excel to PDF. - Issue :Charts not rendered properly
Aspose.Cells.Workbook book = new Aspose.Cells.Workbook("C:\\MyTest.xlsx");
Aspose.Cells.License license = new License();
license.SetLicense("C:\\" + "Aspose.Cells.lic");
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions(SaveFormat.Pdf);
pdfSaveOptions.OnePagePerSheet = true;
for (int i = 0; i < book.Worksheets.Count; i++)
{
book.Worksheets[i].PageSetup.FitToPagesWide = 1;
}
book.SaveOptions.ClearData = true;
book.Save("C:\\Output.pdf", pdfSaveOptions);
2) When i try to convert an worksheet to image. The charts are not rendered well in image.
Aspose.Cells.License license = new License();
license.SetLicense("C:\\" + "Aspose.Cells.lic");
Aspose.Cells.Workbook book = new Aspose.Cells.Workbook("C:\\MyTest.xlsx");
Worksheet sheet = book.Worksheets[0];
Aspose.Cells.Rendering.ImageOrPrintOptions imgOptions;
Aspose.Cells.Rendering.SheetRender sr;
imgOptions = new Aspose.Cells.Rendering.ImageOrPrintOptions();
imgOptions.HorizontalResolution =100;
imgOptions.VerticalResolution = 100;
imgOptions.OnePagePerSheet = true;
imgOptions.IsImageFitToPage = true;
imgOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Tiff;
sr = new Aspose.Cells.Rendering.SheetRender(sheet, imgOptions);
sr.ToImage(0, "C:"+ "\\sheetimage" + ".tiff");
3) When copying one excel to another charts are not rendered well
Aspose.Cells.License license = new License();
license.SetLicense("C:\\" + "Aspose.Cells.lic");
Aspose.Cells.Workbook book = new Aspose.Cells.Workbook("C:\\MyTest.xlsx");
Worksheet ws = book.Worksheets[0];
Aspose.Cells.Workbook New= new Aspose.Cells.Workbook(FileFormatType.Xlsx);
New.Worksheets[0].Copy(ws);
New.Save("C:\\NewFile.xlsx");
Attachments for 1st issue- MyTest.xlsx & Output.pdf
Attachments for 2nd issue - SheetImage.tiff
Attachment for 3rd issue- NewFile.xlsx.