更新时间:2023-12-05 19:21:28
使用 Excel.Workbook.Sheets
集合,更容易访问
Instead of the using Excel.Workbook.Sheets
collection, it's easier to access the Excel.Workbook.Worksheets
collection, that way you can utilize early binding.
在您的情况下,可能看起来像以下内容:
In your case, it could look something like the following:
Excel.Application excelApp = new Excel.Application();
excelApp.Visible = true;
Excel.Workbook workbook = excelApp.Workbooks.Open("C:\MyWorkbook.xls",
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing);
// The key line:
Excel.Worksheet worksheet = (Excel.Worksheet)workbook.Worksheets["SubSignOff"];
希望这有帮助...