Identify charts present in Chart or Worksheet SheetType in Excel file

Hi Team,

I would like to ask about the relationship of charts and worksheets.

I have attached 2 example files: both of them contain a chart which is an object on a sheet in one of the files, but in the other one, the chart was placed to a separate sheet where the chart itself means the sheet actually.

My question is that is there any API call to differentiate these 2 types of chart so that I can decide whether the chart is an object inside a sheet or it is the sheet itself?

I have not found any solutions in Aspose documentations so far, that’s why I am writing to you hoping you can help me. I would be very grateful.

Thanks in advance,
Tamas Boldizsar

charts.zip (19.8 KB)

@tamas.boldizsar,
You may please try the Chart.WorkSheet.Type property to check if the chart is an object or itself is a sheet. Check the following sample code:

Workbook workbook = new Workbook("chart_itself_is_the_sheet.xlsx");
foreach(var sheet in workbook.Worksheets)
{
    foreach (var chart in sheet.Charts)
    {
        Console.WriteLine(chart.Worksheet.Type);
    }
}

Check the following enumerator for your reference.
SheetType

1 Like

@ahsaniqbalsidiqui

Thank you for your suggestion, it helped a lot!

All the best,
Tamas Boldizsar

@tamas.boldizsar,

Good to know that the suggested code segment works for your needs. In the event of further queries or issue, feel free to write us back.

1 Like