为什么我删除excle3行后总是有一行没删掉?
我用C#在向excle模板中写入数据时,想把13行到15行删除掉,代码如下:
int startRowIndex = 13;
int endRowIndex = 16;
for (int i = startRowIndex; i < endRowIndex; i++)
{
m_objSheet.Cells[i, 1].EntireRow.Delete (Excel.XlDirection.xlDown);
}
C# excle 删除行
[解决办法]
索引重置了?
int startRowIndex = 13;
int endRowIndex = 15;
for (int i = endRowIndex; i > startRowIndex; i--)
{
m_objSheet.Cells[i, 1].EntireRow.Delete (Excel.XlDirection.xlDown);
}
------解决方案--------------------
m_objSheet.Cells[15, 1].EntireRow.Delete (Excel.XlDirection.xlDown);
你这样绝对删除看看,能不能删除,如果不能,只有你比我们清楚,为什么不能!!!