How to get the number of CSV sheet's rows?

Excel excel1=new Excel();
excel1.Open(“E:\test.xls”);
int test=excel1.Worksheets[“release”].Cells.Rows.Count;

I can get the number of xls file’s rows,but the following line did not work:

Excel excel3=new Excel();
excel3.OpenCSV(“E:\SHEETWIP.CSV”);
int num=excel3.Worksheets[“SHEETWIP”].Cells.Rows.Count;

How to get the num?

 

You can use Cells.MaxRow - Cells.MinRow + 1 to get number of rows.

@leonidxue,
This is to inform you that Aspose.Cells has replaced Aspose.Excel which is discontinued and no more under active development. Aspose.Cells is much advanced and better in performance when compared with other third-party tools and its predecessor as well. Great support is provided by Aspose.Cells to import/export CSV files. A sample code is here that demonstrates the advanced feature of the loading CSV file with having formula in it.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

TxtLoadOptions opts = new TxtLoadOptions();
opts.Separator = ',';
opts.HasFormula = true;

// Load your CSV file with formulas in a Workbook object
Workbook workbook = new Workbook(dataDir + "sample.csv", opts);

// You can also import your CSV file like this
// The code below is importing CSV file starting from cell D4
Worksheet worksheet = workbook.Worksheets[0];
worksheet.Cells.ImportCSV(dataDir + "sample.csv", opts, 3, 3);

// Save your workbook in Xlsx format
workbook.Save(dataDir + "output_out.xlsx");

A detailed description of this feature is available here:
Load or Import CSV file with Formulas
Save Workbook to Text or CSV Format in Aspose.Cells

Here is a free trial version which can be downloaded from the following link:
Aspose.Cells for .NET (Latest Version)

You can test all the features of this product by downloading a runnable solution here.