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

Free Support Forum - aspose.com

Chart is Shrinking while copying from excel to word

Hi Team,

We are using Aspose.Word.dll ver 6.3.0.0 and Aspose.Cell.dll ver 4.9.0.0 we have licenced for both.

Objective:-We want to copy chart from excelsheet to word doc.

Problem:- Excelsheet has chart and chart contain 2 series (series1,series2) when i copy chart from excelsheet to word doc as a image then one of the chart series is shrinking.

Attachement i) snapshot of word doc . ii) Chart Excelsheet.

i am using this following code for that:-

//////////////////////////////////////////

Workbook myWorkbook = new Workbook();

Document templateDocument = new Document(wordDocumentFilePath);

DocumentBuilder documentBuilder = new DocumentBuilder(templateDocument);

foreach (Worksheet myWorksheet in myWorkbook.Worksheets)

{

foreach (Chart myChart in myWorksheet.Charts)

{

try

{

string bookMarkName;

if (myWorksheet.Name.IndexOf("(") > 0)

{

bookMarkName = myWorksheet.Name.Substring(0, myWorksheet.Name.IndexOf("("));

}

else

{

bookMarkName = myWorksheet.Name;

}

if (templateDocument.Range.Bookmarks[bookMarkName] != null)

{

builder.MoveToBookmark(bookMarkName);

builder.InsertImage(myChart.ToImage());

}

}

catch (Exception ex)

{

//Program.LogException(ex);

}

}

}

templateDocument.Save(@"E:\DocumentTemplate\GeneratedDocument.docx"));

//////////////////////

This problem is occuring on our live server so please provied the solution ASAP.

Thanks

Samanvay

Hi,


It might be some limitation or issue with the older version v4.9 that you are using, but, it works fine with new versions/fix e.g v6.0.1.3 of Aspose.Cells for .NET (Please download: Aspose.Cells for .NET v6.0.1.3.). Here is my sample code, the image is rendered fine of the chart in the template file.
The output image is also attached.

Sample code:
Workbook wb = new Workbook(“e:\test2\SourceChartSheet.xlsx”);
Chart chart = wb.Worksheets[0].Charts[0];
chart.ToImage(@“e:\test2\outsourcechartsheet.bmp”, ImageFormat.Bmp);

Thank you.





Hi Amjad,

Thanx for immediate replay…
yes it was a problem of dll version now it is working fine…

Thanks for support :slight_smile:


Thanks
Samanvay