2021年5月7日星期五

how to check if a excel cell is empty c#

I've been looking for around an hour and a half now to try and find a way to do this, most of the things i find are in visual basic and not c#. The ones in c# just don't work.

            Microsoft.Office.Interop.Excel.Application oXL;              Microsoft.Office.Interop.Excel._Workbook oWB;              Microsoft.Office.Interop.Excel._Worksheet oSheet;              Microsoft.Office.Interop.Excel.Range oRng;                oWB = (Microsoft.Office.Interop.Excel._Workbook)oXL.Workbooks.Open(selectedFileName, 1);              oSheet = (Microsoft.Office.Interop.Excel._Worksheet)oWB.ActiveSheet;                int indexCells = 2;                              if (oSheet.Cells[2, 1].Value2 == null)              {                  while (true)                  {                      if (oSheet.Cells[indexCells, 1].Value2 != null)                      {                          break;                      }                      Thread.Sleep(1);                      Console.Beep(100, 100);                      indexCells++;                  }              }    

I found this somewhere on stack overflow, not going to try and find the link for it but it writes to excel fine, just cant figure out how to check if the cell is empty

any help would be amazing, sorry for not providing the best explanation but i cant thing of anyway else to work it

https://stackoverflow.com/questions/67443437/how-to-check-if-a-excel-cell-is-empty-c-sharp May 08, 2021 at 10:04AM

没有评论:

发表评论