C# EPPlus OpenXML 计数行
对于 EPPlus 和 OpenXML,有人知道如何计算行数的语法吗?
假设我的工作表名为“worksheet”
int numberRows = worksheet.rows.count()
?或 worksheet.rows.dimension
我当然对答案感兴趣,但如何找到答案会很酷,例如“转到定义”并查找这个或那个,等等。
With EPPlus and OpenXML does anyone know the syntax on how to count the rows?
Say my worksheet is called "worksheet"
int numberRows = worksheet.rows.count()
? or worksheet.rows.dimension
I'm certainly interested in the answer, but how to find the answer would be cool to, like "Go to definition" and look for this or that, etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用名为
worksheet
的工作表对象,worksheet.Dimension.Start.Row
和worksheet.Dimension.End.Row
应该为您提供所需的信息。worksheet.Dimension.Address
将为您提供一个字符串,其中包含传统 Excel 范围格式的工作表维度(例如,第 1-5 行、第 1-9 列为“A1:I5”)。有一个可用的文档文件。在许多情况下,使用库并以这种方式找到答案可能同样快。 EPPlus 似乎设计得很好 - 至少一切似乎都有逻辑命名。
With a worksheet object called
worksheet
,worksheet.Dimension.Start.Row
andworksheet.Dimension.End.Row
should give you the information you need.worksheet.Dimension.Address
will give you a string containing the worksheet dimensions in the traditional Excel range format (e.g. 'A1:I5' for rows 1-5, columns 1-9).There is a documentation file available. In many cases it might be just as quick to play around with the library and find the answer that way. EPPlus seems to be well designed - everything seems to be logically named, at least.
谢谢你的提示,Quppa。我用它来从工作簿电子表格填充数据表,如下所示:
Thanks for that tip Quppa. I used it in my bid to populate a DataTable from a Workbook Spreadsheet as below:
我正在使用 4.1 版本,看起来他们添加了一些属性(在之前答案的评论中提到)以使这更容易。
I am working with version 4.1 and it looks like they have added some properties (mentioned in comments from previous answers) to make this easier.
非常简单:
Quite easy with: