Hi,
I am generating a chart and populating it in Excel file. Then I try to copy the chart from Excel and place it in word file as image. But strangely data points are different when we compare the chart in excel file and image in word file. Empty points are treated as Zero value.
Please find the details below:
Step 1: Create a chart and populated in Excel, chart is populated like expected.
Excel file is also attach with the mail.
Also the screen shot of chart is attached.
Step 2: Read the chart and place it in word report as image.
a) Code for reading the charts as image:
List imageStream = new List();
Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook(destinationDir + excelFileName);
if (workbook != null)
{
foreach (Chart chart in workbook.Worksheets[0].Charts)
{
chart.ToImage(chartStream, ImageFormat.Png);
imageStream.Add(chartStream);
}
}
b) Insert the chart in word report:
foreach (MemoryStream image in chartimages)
{
//Set paragraph format
builder.CurrentParagraph.ParagraphFormat.ClearFormatting();
builder.CurrentParagraph.ParagraphFormat.LineSpacingRule = LineSpacingRule.Multiple;
builder.CurrentParagraph.ParagraphFormat.Alignment = ParagraphAlignment.Center;
//insert new paragraph
Paragraph paragraphForChart = builder.InsertParagraph();
//set chart format
Shape shape = new Shape(doc, ShapeType.Image);
shape.ImageData.SetImage(image);
shape.Height = height;
shape.Width = width;
shape.WrapType = WrapType.Inline;
shape.WrapSide = WrapSide.Both;
shape.Left = 0;
paragraphForChart.AppendChild(shape);
}
Every thing is coming as intended but the legends that has value as "{,100,100,100,100,100,100}"
while creating the chart, same while reading the chart. But some how after coping it into image, the chart in image format in word report looks like it has plotted values “{0,0,0,100,100,100,100,100,100}” {note : string is taken from chart object ((Aspose.Cells.Charts.Series)((new System.Collections.ArrayList.ArrayListDebugView(((System.Collections.CollectionBase)(chart.NSeries)).list)).Items[3])).Values }
Issue looks like a strange one. All the screen shoot are attach for the reference. Also the value axis labels (ie Min, Major values) get changed but I think the issue will get resolved if above issue get resolved.
Thank You,
Regards,
Aniket