c# - Excel Interop, iterating workbook for worksheet and chart -
i have scenario while working microsoft excel interop.
system.collections.ienumerator wsenumerator = excelapp.activeworkbook.worksheets.getenumerator(); while (wsenumerator.movenext()) { wscurrent = (excel.worksheet)wsenumerator.current; //worksheet operation follows }
i operating on worksheets, can not have chart in this. want achieve operate on sheets , check if worksheet or chart, , act accordingly.
as sheets contain both worksheet, chart , "excel 4.0 macro", type of sheets each entry can hold of type mentioned.
system.collections.ienumerator wsenumerator = workbookin.sheets.getenumerator(); while (wsenumerator.movenext()) { //identify if chart or worksheet }
solved checking type of current enumerator
var item = wsenumerator.current; if (item excel.chart) { //do chart operations } else if (item excel.worksheet) { //do sheetoperations }