Free Support Forum - aspose.com

Convert MS charts from Excel to Word

Hello, We need to create editable charts (MS charts or Ole charts in word). We have license to Aspose Total, so if it is possible to create in one format and convert to another format it should be alright.
This message was posted using Banckle Live Chat 2 Forum

Hi Imran,

Thanks for your inquiry. Unfortunately, The requested feature is not supported yet in Aspose.Words. We had already logged this feature request as WORDSNET-4617 in our issue tracking system. I have linked this forum thread to the same feature and you will be notified via this forum thread once this feature is available. We apologize for your inconvenience.


However, you can use Aspose.Cells to create charts and convert the charts to image. Once you have image of chart, you can insert that image to Word document by using Aspose.Words as shown in following code snippet.


//Instantiating a Workbook object<o:p></o:p>

Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook();<o:p></o:p>

//Adding a new worksheet to the Excel object<o:p></o:p>

int sheetIndex = workbook.Worksheets.Add();<o:p></o:p>

//Obtaining the reference of the newly added worksheet by<o:p></o:p>

//passing its sheet index<o:p></o:p>

Aspose.Cells.Worksheet worksheet = workbook.Worksheets[sheetIndex];<o:p></o:p>

//Adding a sample value to “A1” cell<o:p></o:p>

worksheet.Cells[“A1”].PutValue(50);<o:p></o:p>

//Adding a sample value to “A2” cell<o:p></o:p>

worksheet.Cells[“A2”].PutValue(100);<o:p></o:p>

//Adding a sample value to “A3” cell<o:p></o:p>

worksheet.Cells[“A3”].PutValue(150);<o:p></o:p>

//Adding a sample value to “B1” cell<o:p></o:p>

worksheet.Cells[“B1”].PutValue(4);<o:p></o:p>

//Adding a sample value to “B2” cell<o:p></o:p>

worksheet.Cells[“B2”].PutValue(20);<o:p></o:p>

//Adding a sample value to “B3” cell<o:p></o:p>

worksheet.Cells[“B3”].PutValue(50);<o:p></o:p>

//Adding a chart to the worksheet<o:p></o:p>

int chartIndex = worksheet.Charts.Add(Aspose.Cells.Charts.ChartType.Pie3D, 5, 0, 15, 5);<o:p></o:p>

//Accessing the instance of the newly added chart<o:p></o:p>

Aspose.Cells.Charts.Chart chart = worksheet.Charts[chartIndex];<o:p></o:p>

//Adding Series Collection (chart data source) to the chart ranging from “A1” cell to “B3”<o:p></o:p>

chart.NSeries.Add(“A1:B3”, true);<o:p></o:p>

//Converting chart to image.<o:p></o:p>

chart.ToImage(MyDir + “Chart.Jpeg”, System.Drawing.Imaging.ImageFormat.Jpeg);<o:p></o:p>

Document doc = new Document();<o:p></o:p>

<o:p> </o:p>

DocumentBuilder builder = new DocumentBuilder(doc);<o:p></o:p>

builder.InsertImage(MyDir + “Chart.Jpeg”);<o:p></o:p>

doc.Save(MyDir + “AsposeOut.docx”);


The issues you have found earlier (filed as WORDSNET-4617) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(18)

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan