更新时间:2023-12-05 19:04:04
相反,使用的 Excel.Workbook.Sheets 集合,它更容易访问的Excel.Workbook.Worksheets 收集,这样你可以利用早期绑定。
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"];
希望这有助于...
Hope this helps...