我试图计算excel中使用过的行。以下是我的代码。将文件名传递给Open()函数时出错。方法'Open'取'1'参数的错误消息是No overload。 我真的很感激任何帮助。谢谢!
public static int GetTableRows(string fileName)
{
Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
var xlWorkbook = xlApp.Workbooks.Open(@fileName);
Microsoft.Office.Interop.Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1];
Microsoft.Office.Interop.Excel.Range xlRange = xlWorksheet.UsedRange;
int rowCount = xlRange.Rows.Count;
return rowCount;
}