且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用C#从Excel文件中删除行

更新时间:2023-11-04 17:02:34

一旦你有了一个参照表说

Once you have a reference to the worksheet say

for(int i = 1; i <=100; i++)
{
  if(!worksheet.Cells[i,1].Contains("SomeString"))
  {
     ((Range)worksheet.Rows[i]).Delete(shiftDirection)
  }
}

在这里shiftDirection在这里看到:Range.Delete方法

您可能不得不投Cell的内容为一个字符串。

You may have to cast the Cell's content to a string.