Hi,
I am displaying the excel chart object on word builder. Since the chart dimensions is more,
I am setting the width and height for the chart object.
Ex: myChart.ChartObject.Height = 300;
myChart.ChartObject.WidthInch = 6.75;
wordBuilder.InsertImage(myChart.ToImage());
When the graph is displayed on word, the values on y axis seem to be wrong in some scenarios.
Ex: If the chart object has the below values on y axis,
0, 10,000 20,000 30,000 40,000 50,000 60,000 70,000 80,000 90,000
In the Word report, the graph has the below values
0, 20,000 40,000 60,000 80,000 100,00(instead of 100,000)
I dont understand why the value is changed to 100,00 instead of 100,000?
Waiting for the reply
Thanks,
Sharanya
Hi,
Hi,
Thanks for your posting and using Aspose.Cells for .NET
Please download and try the latest version:
Aspose.Cells
for .NET v7.2.1.6 and let us know your feedback.
We will need your sample project creating a chart to look into this issue.
Please note:
If the chart’s image is created fine, but changing its dimension on wordBuilder.InsertImage() method, then it is the issue of Aspose.Words and not the issue of Aspose.Cells.
Hi,
Thank you for the quick reply. With the version v7.2.1.6 also, the issue still persists.
Attched chart.png is the chart used for adding to word doc.
The code I used is:
myChart.ChartObject.Height = 300;
myChart.ChartObject.WidthInch = 6.75;
myChart.ValueAxis.TickLabels.NumberFormat = “#,##0”;
wordBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
wordBuilder.InsertParagraph();
wordBuilder.MoveTo(wordBuilder.CurrentParagraph.PreviousSibling);
wordBuilder.InsertImage(myChart.ToImage());
wordBuilder.InsertParagraph();
wordBuilder.MoveTo(wordBuilder.CurrentParagraph);
Attached wordReport.png is the word doc generated with the graph. You can see the value “100,00” instead of "100,000"
Thanks a lot
Sharanya
Hi,
Hi,
Attached is the image that is generated by mychart.toImage() method. Hope this helps you
Thanks,
Sharanya
Hi Sharanya,
Hi,
Attached is the application and the input files.
I am converting the excel chart to image by chart.toImage() method and then then adding this image to the word document.
Please let me know if you need any information in this regard and also I would like to mention that it s bit urgent as we have production release next week
Thanks for understanding
-Sharanya
Hi,
Workbook myWorkbook = new Workbook(“J:\chart.xlsx”);
//Obtain the chart from the first worksheet
Chart myChart = myWorkbook.Worksheets[0].Charts[0];
//Set the height of the chart
myChart.ChartObject.Height = 300;
//Set the width of the chart
myChart.ChartObject.WidthInch = 6.75;
//Format value and Category Axis as required
myChart.ValueAxis.TickLabels.NumberFormat = “#,##0”;
myChart.CategoryAxis.TickLabels.RotationAngle = 45;
//Export the image for testing
myChart.ToImage(“E:\chart.png”, System.Drawing.Imaging.ImageFormat.Png);
//Save the workbook as well for testing
myWorkbook.Save(“E://chartOutput.xlsx”);
Hi,
We have fixed the bug that the maximum scale of y axis is wrong.
Please download and try the latest fix: Aspose.Cells for .NET v7.2.1.7
Thank you very much for the library. That fixed my issue.
I have one more doubt. Please refer my earlier input files attachment.
You can see that the values on y axis are numbers(chart.xlsx). When I put it into word, the format of the number is in decimal. So I had to give the number format “#,##0” explicitly.
Cannot figure out why the the numbe format is not taken by word
Again, Thank you so much. Waiting for your reply
-Sharanya
Hi Sharanya,
Thank you for your feedback.
If the display/export using Aspose.Cells is fine now, then it’s not an issue at Aspose.Cells end. This seems to be something related to Aspose.Words. I think you are embedding the chart as an image using Word, is it so?
Hi,
Export is fine only if I give the number format “#,##0”. Please find attached ConsoleApplication1.zip which has the complete code to replicate the issue.
Also, find Inputfiles.zip which has the input files
Please let me know if you need anything from me.
Thanks a lot,
Sharanya
Hi,
Hi,
Hi,sharanya:Hi,
Export is fine only if I give the number format "#,##0". Please find attached ConsoleApplication1.zip which has the complete code to replicate the issue.
Also, find Inputfiles.zip which has the input files
Please let me know if you need anything from me.
Thanks a lot,
Sharanya
I have looked into your issue and found you are using older version. Please download and use the latest version: Aspose.Cells for .NET v7.2.1.9 It is working fine
Please see the code below as you can see the generated chart image is fine. The number format is appearing fine on Y-axis.
I have extracted the code from your console application project.
C#
string filePath = @"F:\Shak-Data-RW\Downloads\Inputfiles\chart.xlsx";
Workbook workbook = new Workbook(filePath);
Worksheet worksheet = workbook.Worksheets[0];
Chart myChart = worksheet.Charts[0];
myChart.ChartObject.Height = 300;
myChart.ChartObject.WidthInch = 6.75;
myChart.CategoryAxis.TickLabels.RotationAngle = 45;
myChart.ToImage(filePath + ".out.png", System.Drawing.Imaging.ImageFormat.Png);
Hi,
If you observe in my attached chart.xlsx, there is a number format([=0]0;[<10]0.0#;#,##0). So the numbers are displayed as comma separated values.
But my intermediate exported chart image has the y axis values as decimal format. My understanding is that it has to be in comma separated format.
Please correct me if I am wrong
Thanks,
Sharanya
Hi,
Could you please fix the above image (chart.xlsx.out.png) using Ms-Paint and attach it here.
It will help us quickly sort out your issue.
Hi,
Thank you so much. This solved my problem. I hope this build also has the fix for my earlier problem(problem is mentioned in the earlier posts in the same thread). ie.,
If the chart object has the below values on y axis,
0, 10,000 20,000 30,000 40,000 50,000 60,000 70,000 80,000 90,000
In the Word report, the graph has the below values
0, 20,000 40,000 60,000 80,000 100,00(instead of 100,000)
I get this kind of report very rare. So cannot produce at my end.
Thanks a lot,
Sharanya
Hi,
It’s good to know your problem is resolved.
If you find any other problem or have some unanswered questions, please feel free to post.
We will help you asap.