Insert text in specific cell in Excel c#

前端 未结 1 1993
南方客
南方客 2021-01-22 20:23

I need to insert text in 5th row ist column and another text in 5th row 2nd column... How do I do this? Below is the code am using and get out of range exception:



        
相关标签:
1条回答
  • 2021-01-22 21:00

    Before the cell insertion above you have to add a worksheet

    Excel.Application excelApplication = new Excel.Application();
    Excel.Workbook excelWorkBook = excelApplication.Workbooks.Add();
    Excel.Worksheet wkSheetData = excelWorkBook.ActiveSheet;
    excelApplication.Cells[5, 2] = "TextField";
    

    I hope this helps

    0 讨论(0)
提交回复
热议问题