我试图通过使用Microsoft Interop c#来检测Microsoft Excel中的单元格是否包含数据透视表
我想要做的是循环遍历所有单元格,如下面的代码所示,然后如果单元格包含数据透视表,我想将该单元格的行和列信息存储为整数值,如下所示:
int rowCount = xlRange.Rows.Count;
int colCount = xlRange.Columns.Count;
Excel.Range cell = null;
for (int iRow = 1; iRow < rowCount; iRow++)
{
for (int iCol = 1; iCol <= colCount; iCol++)
{
/* This line of code is probably wrong */
cell = xlRange.Cells[iRow, iCol] as Excel.Range;
if(/*Cell contains PivotTable*/)
{
int rowLocation = iRow;
int colLocation = iCol;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我已经尝试过查看MSDN和其他来源,但似乎无法找到任何方法来检测单元格是否包含数据透视表.
任何帮助表示赞赏,谢谢.