Excel.Chart.Export not working

c#, excel

Solution

Exporting charts that are not at least partially visible on screen at the time of the call to .Export appears to result in the blank images.

Try adding a line of code to activate the chart to be exported before you export it (I ran into the same issue and this worked for me):

Excel.ChartObject chart = (Excel.ChartObject)chartObjects.Item(j);
path = Path.Combine(Application.StartupPath, @"Img\" + chart.Chart.Name + ".bmp");
chart.Activate(); //New line
chart.Chart.Export(path, "BMP", true);

Problem

I have excel file with multiple chart on a sheet. I get chart from excel and save it to picture. My code: ``` workSheet = workBook.Sheets[1] as Excel._Worksheet; Excel.ChartObjects chartObjects =(Excel.ChartObjects)workSheet.ChartObjects(Type.Missing); int chartCount = chartObjects.Count; for (int j = 1; j <= chartCount; j++) { Excel.ChartObject chart = (Excel.ChartObject)chartObjects.Item(j); path = Path.Combine(Application.StartupPath, @"Img\" + chart.Chart.Name + ".bmp"); chart.Chart.Export(path, "BMP", true); } ``` but only blank picture is exported. Please help me

Original source

Related problems