Read mass data from Excel 2003

Z

zlf

Hi all£º
I am trying to read data from Excel 2003, However, I found the method
I taken below (C# code) is too inefficient. Read a 250x250 sized matrix will
take several
minutes. May u provide me some high efficient method to solve mass data
reading problem(VBA code also will be OK)£¿Thanks


int ColNum = mySheet.UsedRange.Columns.Count;
int RowNum = mySheet.UsedRange.Rows.Count;

Range range = mySheet.get_Range(mySheet.Cells[1, 1],
mySheet.Cells[RowNum, ColNum]);
...
for (int i = 1; i <= RowNum; ++ i)
{
DataRow dr;
dr = dt.NewRow();

for (int j = 1; j <= ColNum; ++ j)
{
dr[j - 1] = ((Range) range.get_Item(i, j)).Text.ToString();
}
dt.Rows.Add((dr));
}


zlf
 
C

Cindy M -WordMVP-

Hi Zlf,
I am trying to read data from Excel 2003, However, I found the method
I taken below (C# code) is too inefficient. Read a 250x250 sized matrix will
take several
minutes. May u provide me some high efficient method to solve mass data
reading problem
One possibility would be to use an ODBC or OLE DB connection to read the file
without opening it. Another would be to save the file as XML, then read and
process the XML.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top