C#: How to access an Excel cell?

后端 未结 7 1113
忘掉有多难
忘掉有多难 2020-12-05 18:25

I am trying to open an Excel file and populate its cells with data? I have done the following coding so far.

Currently I am at this stage with the following code but

7条回答
  •  萌比男神i
    2020-12-05 19:23

    Try:

    Excel.Application oXL;
    Excel._Workbook oWB;
    Excel._Worksheet oSheet;
    Excel.Range oRng;
    
    oXL = new Excel.Application();
    oXL.Visible = true;
    oWB = (Excel._Workbook)(oXL.Workbooks.Add(Missing.Value));
    
    oSheet = (Excel._Worksheet)oWB.Worksheets;
    oSheet.Activate();
    
    oSheet.Cells[3, 9] = "Some Text"
    

提交回复
热议问题