我使用ClosedXML和C#来修改Excel工作簿。我需要找到最后使用的行号,但是.RowCount()
会计算工作表中有多少行。因此,当只有几千行时,它将返回100万行。我尝试过LastRowUsed()
,但它不返回int,也没有.row
方法。怎样才能得到int中的最后一行?
发布于 2017-01-31 21:57:47
您可以使用RowsUsed();
var wb = new XLWorkbook();
var ws = wb.worksheets.add("data");
var totalRows = ws.RowsUsed().Count();
发布于 2017-02-01 13:12:43
LastRowUsed()
函数返回一个row对象。使用
worksheet.LastRowUsed().RowNumber()
若要获取最后一行的使用编号,请执行以下操作。
发布于 2017-01-31 21:39:57
你必须使用.LastRowUsed()
来自official GitHub repo的更有用的东西:
range.FirstCell()
range.FirstCellUsed()
range.FirstColumn()
range.FirstColumnUsed()
range.FirstRow()
range.FirstRowUsed()
range.LastCell()
range.LastCellUsed()
range.LastColumn()
range.LastColumnUsed()
range.LastRow()
range.LastRowUsed()
https://stackoverflow.com/questions/41967611
复制相似问题