I reproduced your problem, but I haven't been able to solve it yet.
But I used the Open XML SDK 2.5 Productivity Tool to generate a very lengthy code based on an excel file with only a blank chartsheet.
I will provide it to you as an attachment, if you are interested, you can take a look.
Whether we can use other packages, I wrote a piece of code using Microsoft.Office.Interop.Excel, it is much simpler.
Application xl = null;
_Workbook wb = null;
try
{
xl = new Application();
xl.Visible = true;
wb = (_Workbook)(xl.Workbooks.Add(XlWBATemplate.xlWBATWorksheet));
Worksheet worksheet = (Worksheet)wb.ActiveSheet;
var charts = worksheet.ChartObjects() as
Microsoft.Office.Interop.Excel.ChartObjects;
var chartObject = charts.Add(60, 10, 300, 300) as
Microsoft.Office.Interop.Excel.ChartObject;
var chart = chartObject.Chart;
chart.Location(XlChartLocation.xlLocationAsNewSheet, Type.Missing);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
finally
{
wb.SaveAs(@"C:\xxx\1.xlsx");
wb.Close();
xl.Quit();
}
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.