【发布时间】:2016-02-25 09:51:08
【问题描述】:
我正在尝试使用 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;
}
}
}
我尝试查看MSDN 和其他来源,但似乎找不到任何方法来检测单元格是否包含数据透视表。
感谢您的帮助。
【问题讨论】: