Excel Graphs within word

We have a requirement to embed excel charts within word and then convert to PDF. Can this all be done in memory as we do not want to create an excel worksheet on the hard drive. There is no requirement to keep the excel chart data - just the word and pdf documents (the word documents will be used as templates using aspose smart tags).
Can I just use aspose word to perform this task and if so how do i generate the excel graphs?
Or do I have to use a combination of Aspose Word and Aspose Excel and embed as an OLE object?

Hi
James,

Thanks for your inquiry.
Yes, you can insert excel charts as images within word without saving excel sheets on the hard drive.
Secondly, of course you need to combine Aspose.Word & Aspose.Excel to generate graphs.

Here is a sample code:

// Initialize Document Document objDocument = new Document();
// Create DocumentBuilder so we can modify the document.
DocumentBuilder objDocumentBuilder = new DocumentBuilder(objDocument);
DataTable datatable; //get your datatable from any datasource
// Add Area3D chart image into the document.
objImage = GetArea3DImage(ChartType.Area3D, datatable, "title");
objDocumentBuilder.InsertImage(objImage);
objDocument.Save(@"C:\WordReports\NetworkSummary-ASP-NET.docx", Aspose.Words.SaveFormat.Doc);
private System.Drawing.Image GetArea3DImage(ChartType chartType, DataTable objDataTable, string chartTitle)
{
    // Initialize DataLabels
    DataLabels objDataLabels = null;
    // Initialize Workbook
    Workbook objWorkbook = new Workbook();
    // Initialize worksheet
    Worksheet objWorksheet = objWorkbook.Worksheets[0];
    // Initialize Cells
    Aspose.Cells.Cells objCells = objWorksheet.Cells;
    objCells.ImportDataTable(objDataTable, true, "A1");
    int chartIndex = objWorksheet.Charts.Add(chartType, 2, 3, 30, 12);
    Chart objChart = objWorksheet.Charts[chartIndex];
    // Set some visual options.
    objChart.PlotArea.Area.ForegroundColor = Color.White;
    objChart.PlotArea.Border.IsVisible = false;
    // Set input data ranges.
    objChart.NSeries.Add("C2:C" + (objDataTable.Rows.Count + 1).ToString(), true);
    objChart.NSeries.CategoryData = "A2:A" + (objDataTable.Rows.Count + 1).ToString();
    objChart.NSeries.IsColorVaried = true;
    // Set properties of chart title
    objChart.Title.Text = chartTitle;
    objChart.Title.TextFont.Color = Color.Black;
    objChart.Title.TextFont.IsBold = true;
    objChart.Title.TextFont.Size = 12;
    // Set the legend position type
    objChart.Legend.Position = LegendPositionType.Top;
    for (int i = 0; i <objChart.NSeries.Count; i++)
    {
        objDataLabels = objChart.NSeries[i].DataLabels;
        objDataLabels.ShowValue = true;
        objDataLabels.TextFont.Size = 14;
        objDataLabels.TextFont.IsBold = true;
        objDataLabels.Position = LabelPositionType.Above;
        objChart.NSeries[i].Name = objCells[1 + i, 1].Value.ToString();
    }
    return objChart.ToImage();
}

In case of any ambiguity, please let me know.

Thank you for the quick reply. I have had another look at the requirements and we will have to use the mail merge facility. The document will be populated dynamically and will require a number of images to be mail merged (as they have to be located within specific areas - for example side by side with text).
Is is possible to mail merge the excel object (as per your code) using aspose words?

Hi James,

Thanks for your inquiry.

Our apologises for the delayed response. Sure, you can insert an Excel chart as an image during mail merge by using the field merging callback.

Please see the page here for details:
https://docs.aspose.com/words/net/types-of-mail-merge-operations/

Thanks,