C#: Getting the number of rows/columns with ExcelPackage

后端 未结 9 630
执念已碎
执念已碎 2021-02-03 18:59

I need to read and write data from an Excel spreadsheet. Is there a method to finding out how many rows/columns a certain worksheet has using ExcelPackage? I have the following

相关标签:
9条回答
  • 2021-02-03 19:36

    I have looked up a few websites using ExcelPackage library.
    Also, the page on codeplex has a question on - how to get the number of rows/columns?

    It seems there isn't a support of it. Sorry, the documentation is not available as well.
    You will have to iterate on rows/columns (keeping in mind the max rows/columns the spreadsheet can hold) and check whether the cell contains any value.

    See this link - http://web.archive.org/web/20110123164144/http://nayyeri.net/use-excelpackage-to-manipulate-open-xml-excel-files (original link dead)

    0 讨论(0)
  • 2021-02-03 19:41

    The best way to get the total of rows and columns is with these methods:

    int col = sheet.Dimension.Columns;
    int row = sheet.Dimension.Rows;
    
    0 讨论(0)
  • 2021-02-03 19:42
    int row = _excelSheet.Rows.CurrentRegion.EntireRow.Count;
    int col = _excelSheet.Columns.CurrentRegion.EntireColumn.Count;
    
    0 讨论(0)
提交回复
热议问题