Aspose is a powerful control that can be used to manipulate files such as word,excel,ppt, and it is very convenient to import and export data using this control. Where Aspose.cells is used to manipulate Excel, there are many features. I'm using the most basic functionality, reading the data from Excel and importing it into a dataset or database. The code for reading the Excel tabular data is as follows:
The first step is to introduce a namespace: using Aspose.cells;
New Workbook (); Workbook. Open ("c:\\test.xlsx"); Cells cells = workbook. Worksheets[0]. Cells; For (int i = 0; i < cells. Maxdatarow + 1; i++) {for (//A row of read data, the code inserted into the database can also be written here}}
Return to DataTable:
Cells cells = workbook. WORKSHEETS[1]. Cells; System.Data.DataTable DataTable1 = cells. Exportdatatable (1, 0, cells. Maxdatarow,cells. Maxcolumn); //nonetitlesystem.data.datatable dataTable2 = cells. Exportdatatable (0, 0, cells. Maxdatarow+1,cells. Maxcolumn,true);//showtitle
Originating From: http://www.cnblogs.com/ricky_li/p/3738005.html
Aspose is a powerful control that can be used to manipulate files such as Word,excel,ppt