【发布时间】:2017-05-23 08:36:33
【问题描述】:
我有一个包含 10 个表格的 Word 文档。当我读取这些表中的值时,我想警告操作员检查第 5 页的表 4。 我可以得到表号,但是有没有办法在那个表的页面上指出?我的代码片段如下:
int nTable = 0;
int nPage = 0;
foreach (Word.Table tb in doc.Tables)
{
nTable++;
nPage = PageNumberForTable(nTable); // I need a function like this
numRows = tb.Rows.Count;
numColumns = tb.Columns.Count;
for (int row = 1; row <= numRows; row++)
{
for(int col = 1; col <= numColumns; col++)
{
var cell = tb.Cell(row, col);
cellValue = CleanRASpace(cell.Range.Text);
if(cellValue == 2)
{
MessageBox.Show("Check table " + nTable + " on page " + nPage);
}
}
}
}
【问题讨论】:
标签: c# ms-word automation office-interop