C#: How to copy excel cell range and chart data to power point slides
-
i have data and chart in excel work sheet which i need to copy at run time from excel to power point slides. i have a code which is working fine but the code only can copy chart data to excel sheet not range data. please see the scree shot of my excel. so anyone can get idea how data is there in my work sheet which i need to copy to power point slide programmatically. enter image description here screen shot url....please see it. [screen shot url] here is code which i am using to copy range data and chart data to power point dynamically.
private void Form1_Load(object sender, EventArgs e)
{
pptNS.ApplicationClass powerpointApplication = null;
pptNS.Presentation pptPresentation = null;
pptNS.Slide pptSlide = null;
pptNS.ShapeRange shapeRange = null;xlNS.ApplicationClass excelApplication = null; xlNS.Workbook excelWorkBook = null; xlNS.Worksheet targetSheet = null; xlNS.ChartObjects chartObjects = null; xlNS.ChartObject existingChartObject = null; xlNS.Range destRange = null; string paramPresentationPath = @"D:\\test\\Chart Slide.pptx"; string paramWorkbookPath = @"D:\\test\\MyExcelData.xlsx"; object paramMissing = Type.Missing; try { // Create an instance of PowerPoint. powerpointApplication = new pptNS.ApplicationClass(); // Create an instance Excel. excelApplication = new xlNS.ApplicationClass(); // Open the Excel workbook containing the worksheet with the chart // data. excelWorkBook = excelApplication.Workbooks.Open(paramWorkbookPath, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing); // Get the worksheet that contains the chart. targetSheet = (xlNS.Worksheet)(excelWorkBook.Worksheets\["Spain"\]); // Get the ChartObjects collection for the sheet. chartObjects = (xlNS.ChartObjects)(targetSheet.ChartObjects(paramMissing)); // Create a PowerPoint presentation. pptPresentation = powerpointApplication.Presentations.Add(
-
i have data and chart in excel work sheet which i need to copy at run time from excel to power point slides. i have a code which is working fine but the code only can copy chart data to excel sheet not range data. please see the scree shot of my excel. so anyone can get idea how data is there in my work sheet which i need to copy to power point slide programmatically. enter image description here screen shot url....please see it. [screen shot url] here is code which i am using to copy range data and chart data to power point dynamically.
private void Form1_Load(object sender, EventArgs e)
{
pptNS.ApplicationClass powerpointApplication = null;
pptNS.Presentation pptPresentation = null;
pptNS.Slide pptSlide = null;
pptNS.ShapeRange shapeRange = null;xlNS.ApplicationClass excelApplication = null; xlNS.Workbook excelWorkBook = null; xlNS.Worksheet targetSheet = null; xlNS.ChartObjects chartObjects = null; xlNS.ChartObject existingChartObject = null; xlNS.Range destRange = null; string paramPresentationPath = @"D:\\test\\Chart Slide.pptx"; string paramWorkbookPath = @"D:\\test\\MyExcelData.xlsx"; object paramMissing = Type.Missing; try { // Create an instance of PowerPoint. powerpointApplication = new pptNS.ApplicationClass(); // Create an instance Excel. excelApplication = new xlNS.ApplicationClass(); // Open the Excel workbook containing the worksheet with the chart // data. excelWorkBook = excelApplication.Workbooks.Open(paramWorkbookPath, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing, paramMissing); // Get the worksheet that contains the chart. targetSheet = (xlNS.Worksheet)(excelWorkBook.Worksheets\["Spain"\]); // Get the ChartObjects collection for the sheet. chartObjects = (xlNS.ChartObjects)(targetSheet.ChartObjects(paramMissing)); // Create a PowerPoint presentation. pptPresentation = powerpointApplication.Presentations.Add(
What you should do is find out how to do it manually, and once you know nomenclature, you'll know how to google how to do it in code. Here's a place to start: [Import data from Excel into PowerPoint - PowerPoint](https://support.office.com/en-us/article/Import-data-from-Excel-into-PowerPoint-3ec295e9-1bfd-47ff-8d7d-8b838caef853)
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013