Read number of Rows filled in excel sheet

Topics: Developer Forum, Project Management Forum, User Forum
Dec 31, 2009 at 12:20 PM

I am presently using the below code for looping through cells in excel sheet.

 I want to change that value (6)  based on the number of rows filled in excel sheet. Any body Help me out!!

   using (ExcelPackage xlPackage = new ExcelPackage(existingFile))
   {
    // get the first worksheet in the workbook
    ExcelWorksheet worksheet = xlPackage.Workbook.Worksheets[1];
    int iCol = 2;  // the column to read
    
    // output the data in column 2
    for (int iRow = 1; iRow < 6; iRow++)
     Console.WriteLine("\tCell({0},{1}).Value={2}", iRow, iCol, worksheet.Cell(iRow, iCol).Value);

    // output the formula in row 6
    Console.WriteLine("\tCell({0},{1}).Formula={2}", 6, iCol, worksheet.Cell(6, iCol).Formula);

   } // the using statement automatically calls Dispose() which closes the package.

 

 

 

 

Jan 2, 2010 at 4:58 AM

I found the solution here

http://excelpackage.codeplex.com/WorkItem/View.aspx?WorkItemId=8663