Aspose.Cells for .NET (VB.NET)

Good evening,

I have been tasked with a project which I think will require your
component for .NET.   I have been on your site a few times now reading
through the documentation but have been unable to find an example of
how to do the following:

1. open an excel workbook (found on your site how to do this)
2. read the excel sheet(s) line by line (with the intent to import the
data to a database) (read row by row, cell by cell)

Can you please provide a URL to where I can see a demo / source code of this?
Thank you.


This message was posted using Email2Forum by ShL77.

Hi,

Well, using Aspose.Cells API, you may Open your Excel file and then obtain the values in different cells in the worksheet(s)
(looping through the cells) for your need. Moreover, you can even directly export data
of a complete worksheet to fill a DataTable or even an array for your
need too so you may later update your database based on the values in
the DataTable.

See the sample code below:
Sample code:

Dim workbook As New Workbook()
workbook.Open(“e:\test\Book1.xls”)
'Get the first worksheet cells collection
Dim cells As Cells = workbook.Worksheets(0).Cells
//Loop through each cell (row by row) in the worksheet and get the cell values.
For i As Integer = 0 To cells.MaxDataRow - 1
For j As Integer = 0 To cells.MaxDataColumn - 1
Console.WriteLine(cells(i, j).StringValue)

Next j
Next i

'You can export the data of a complete worksheet to fill a data table if you want.
Dim dt As DataTable = cells.ExportDataTable(0, 0, cells.MaxDataRow + 1, cells.MaxDataColumn + 1)

'Your code goes here



For further reference, please see the documents:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/retrieving-data-from-cells.html
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/exporting-data-from-worksheets.html

Also check the demos:




Thank you.