read through an excel spreadsheet in visual basic .net

  • Thread starter Thread starter Amaryllis
  • Start date Start date
A

Amaryllis

Hi,

I am working on a Windows application that will read through an excel
spreadsheet of unknown size and upload the information to a file on
AS/400. I have installed the PIAs needed to connect via COM, and
have gotten as far as opening the spreadsheet. My problem is
figuring out how to loop through the cells and gather the information
one row at a time since I don't have a set range of cells. I would
appreciate any input.

Thanks
 
Just out of curiosity - why are you using COM? Why not use
System.Data.Oledb and pipe through Excel's driver?
 
Well,

I could use OLEDB as well or ADO, but either way, I'm still not sure
how to capture the data from each row and pipe it to the 400 since I
don't have a set number of rows to assign to the range.

As far as why I am using VB, we are a small Microsoft shop and that's
the best choice we have for an automated upload process.
 
If I understand you question right, you can read cell contents as follows but you need to make the worksheet the active sheet:

dim w as excel.Worksheet

for i= 1 to rows (however many rows you want to read
for j=1 to cols (however many cols you want to read in each row
value=w.cells(i,j)
'store your value somewhere
next j
next i
 
Back
Top