473,466 Members | 1,370 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Excel Data

Does anyone know a way to import excel data very fast?

I have spreadsheet data that has to be processed, the spreadsheet has 256
columns and 20,000 rows of data. That's 5,120,000 cells.

The cells can contain any type of data, but the data has to be coverted to
Double arrays. Currently I read the data from the spreadsheed using OleDB
and put the data into datagrid which is not too bad - takes maybe a minute,
but when I move the data from the datagrid to double array by looping
through each row and column the process takes about and hour on my laptop
with 512 mb. The process is slow because I have to test each cell to make
sure it's double type and put zero in the array if it's not.

Does anyone know a way to either move the data from the grid into the array
very fast or convert the data in the datagrid to double before I start
moving the data into arrays very fast.
Thank you
Peter

Feb 10 '06 #1
4 9112
Peter,

Do you REALLY need to show 20000 rows of data at the same time? A user
can't possibly process that much at one time.

If you really have to show all of this data at one time, then what I
would recommend is having a virtual view, which is connected to the excel
sheet and then fetching only the values that are shown when you need to show
them. Trying to store all of that data in memory is going to cost you (as
you have already seen).

The DataGridView control in .NET 2.0 has a virtual mode that you can use
to do this. In .NET 1.1, you will have to use a third party grid which
supports a virtual mode.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Peter" <pc*****@nospam.nospam> wrote in message
news:uH*************@TK2MSFTNGP15.phx.gbl...
Does anyone know a way to import excel data very fast?

I have spreadsheet data that has to be processed, the spreadsheet has 256
columns and 20,000 rows of data. That's 5,120,000 cells.

The cells can contain any type of data, but the data has to be coverted to
Double arrays. Currently I read the data from the spreadsheed using OleDB
and put the data into datagrid which is not too bad - takes maybe a
minute, but when I move the data from the datagrid to double array by
looping through each row and column the process takes about and hour on my
laptop with 512 mb. The process is slow because I have to test each cell
to make sure it's double type and put zero in the array if it's not.

Does anyone know a way to either move the data from the grid into the
array very fast or convert the data in the datagrid to double before I
start moving the data into arrays very fast.
Thank you
Peter

Feb 10 '06 #2

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:ej**************@TK2MSFTNGP09.phx.gbl...
Peter,

Do you REALLY need to show 20000 rows of data at the same time? A user
can't possibly process that much at one time.

If you really have to show all of this data at one time, then what I
would recommend is having a virtual view, which is connected to the excel
sheet and then fetching only the values that are shown when you need to
show them. Trying to store all of that data in memory is going to cost
you (as you have already seen).

The DataGridView control in .NET 2.0 has a virtual mode that you can
use to do this. In .NET 1.1, you will have to use a third party grid
which supports a virtual mode.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Peter" <pc*****@nospam.nospam> wrote in message
news:uH*************@TK2MSFTNGP15.phx.gbl...
Does anyone know a way to import excel data very fast?

I have spreadsheet data that has to be processed, the spreadsheet has 256
columns and 20,000 rows of data. That's 5,120,000 cells.

The cells can contain any type of data, but the data has to be coverted
to Double arrays. Currently I read the data from the spreadsheed using
OleDB and put the data into datagrid which is not too bad - takes maybe a
minute, but when I move the data from the datagrid to double array by
looping through each row and column the process takes about and hour on
my laptop with 512 mb. The process is slow because I have to test each
cell to make sure it's double type and put zero in the array if it's not.

Does anyone know a way to either move the data from the grid into the
array very fast or convert the data in the datagrid to double before I
start moving the data into arrays very fast.
Thank you
Peter



I am using DataGrid on .NET 1.1

DataGrid is not a problem, even with 20000 rows works fine. The problem I
am having is moving the data into Double array.
I am creating graphs for each column of the DataGrid using ZedGraph library
http://zedgraph.sourceforge.net/
ZedGraph is expecting Doubles and I am creating 256 graphs at one time so
user can scroll through the graphs, that's why I need to convert this data
into arrays.
Once the data is converted the performace is accaptable, but one hour to
convert is not acceptable, nobody is going to wait that long.

So main question is how do I move large object array in to Double array very
fast,?
Feb 10 '06 #3
Hi,
Does anyone know a way to import excel data very fast?

I have spreadsheet data that has to be processed, the spreadsheet has
256 columns and 20,000 rows of data. That's 5,120,000 cells.
As the other poster said, this is a lot of data... so I would look to
see if there is something that can be done there to reduce it. But even
if this is already the less data you need, you can still load it very
fast.
The cells can contain any type of data, but the data has to be
coverted to Double arrays. Currently I read the data from the
spreadsheed using OleDB and put the data into datagrid which is not
too bad - takes maybe a minute, but when I move the data from the
datagrid to double array by looping through each row and column the
process takes about and hour on my laptop with 512 mb. The process
is slow because I have to test each cell to make sure it's double
type and put zero in the array if it's not.


2 things here.
First, I don't think this is related to converting to doubles, this
should be very fast.
There might be 2 reasons for this being slow:
a)OleDb is not really loading the data on that minute, but only some
records. When you actually read the values there is when it loads the
valus from the xls file.
b) A datagrid is slow because it has to visually update the data. Can
you load the data into a dataset instead? this should be quite faster.

Second thing, if you are serious about xls files, I would look for a
third party option. There are a lot of them, and for a reason...

We develop one of those solutions so I will only speak about it, but
you can google around for the others.

I wanted to test how the speed would be, so I created a file with 256
columns, with value 1 on column 1, 2 on 2... etc . Then I copied the
row 20,000 times and added some random data so it would not be so easy.

I tried it with our program, and it took a little less than 10 seconds
to read the whole file and fill the double[][] arrays. (on a 3ghz
pentium 512 mb ram laptop)

If you want to test it yourself, go to
www.tmssoftware.com/go/?flexcelnet

and download our product. Then create a new windows project, add a
reference to flexcel.dll, and add this using clauses:
using FlexCel.Core;
using FlexCel.XlsAdapter;

After that, drop a button on a form, double click it and paste this
code:

private void button1_Click(object sender, System.EventArgs e)
{
DateTime StartTime = DateTime.Now;
XlsFile xls = new XlsFile(true);
xls.Open("toomanycells.xls");
double[][] data = new double[xls.RowCount][];

for (int r = xls.RowCount; r >0; r --)
{
data[r-1] = new double[256];
for (int cindex = xls.ColCountInRow(r); cindex > 0;
cindex--)
{
int c = xls.ColFromIndex(r, cindex);
int XF = 0;
object o = xls.GetCellValueIndexed(r, cindex, ref
XF);
if (o is double)
{
data[r-1][c-1] = (double) o;
}
else
{
TFormula f = o as TFormula;
if (f!=null)
{
if (f.Result is double)
{
data[r][c] = (double)f.Result;
}
}

}
}
}
DateTime EndTime = DateTime.Now;

MessageBox.Show((EndTime - StartTime).ToString());

}
}
I am really interested in knowing your numbers with your file. Please
if you decide to try it let me know how it goes. (or just post an
answer here) Remember to compile on release mode for the test, even
when that will not afect the results very much.

Hope this helps
Best regards,
Adrian.

Feb 10 '06 #4
I got the same results as you did, the problem was using Convert.ToDouble
method - that's what was slowing it down.

I do like your control and I will buy it.

"Adrian Gallero" <ag***********@SPAMnetscape.net> wrote in message
news:eD**************@TK2MSFTNGP12.phx.gbl...
Hi,
Does anyone know a way to import excel data very fast?

I have spreadsheet data that has to be processed, the spreadsheet has
256 columns and 20,000 rows of data. That's 5,120,000 cells.


As the other poster said, this is a lot of data... so I would look to
see if there is something that can be done there to reduce it. But even
if this is already the less data you need, you can still load it very
fast.
The cells can contain any type of data, but the data has to be
coverted to Double arrays. Currently I read the data from the
spreadsheed using OleDB and put the data into datagrid which is not
too bad - takes maybe a minute, but when I move the data from the
datagrid to double array by looping through each row and column the
process takes about and hour on my laptop with 512 mb. The process
is slow because I have to test each cell to make sure it's double
type and put zero in the array if it's not.


2 things here.
First, I don't think this is related to converting to doubles, this
should be very fast.
There might be 2 reasons for this being slow:
a)OleDb is not really loading the data on that minute, but only some
records. When you actually read the values there is when it loads the
valus from the xls file.
b) A datagrid is slow because it has to visually update the data. Can
you load the data into a dataset instead? this should be quite faster.

Second thing, if you are serious about xls files, I would look for a
third party option. There are a lot of them, and for a reason...

We develop one of those solutions so I will only speak about it, but
you can google around for the others.

I wanted to test how the speed would be, so I created a file with 256
columns, with value 1 on column 1, 2 on 2... etc . Then I copied the
row 20,000 times and added some random data so it would not be so easy.

I tried it with our program, and it took a little less than 10 seconds
to read the whole file and fill the double[][] arrays. (on a 3ghz
pentium 512 mb ram laptop)

If you want to test it yourself, go to
www.tmssoftware.com/go/?flexcelnet

and download our product. Then create a new windows project, add a
reference to flexcel.dll, and add this using clauses:
using FlexCel.Core;
using FlexCel.XlsAdapter;

After that, drop a button on a form, double click it and paste this
code:

private void button1_Click(object sender, System.EventArgs e)
{
DateTime StartTime = DateTime.Now;
XlsFile xls = new XlsFile(true);
xls.Open("toomanycells.xls");
double[][] data = new double[xls.RowCount][];

for (int r = xls.RowCount; r >0; r --)
{
data[r-1] = new double[256];
for (int cindex = xls.ColCountInRow(r); cindex > 0;
cindex--)
{
int c = xls.ColFromIndex(r, cindex);
int XF = 0;
object o = xls.GetCellValueIndexed(r, cindex, ref
XF);
if (o is double)
{
data[r-1][c-1] = (double) o;
}
else
{
TFormula f = o as TFormula;
if (f!=null)
{
if (f.Result is double)
{
data[r][c] = (double)f.Result;
}
}

}
}
}
DateTime EndTime = DateTime.Now;

MessageBox.Show((EndTime - StartTime).ToString());

}
}
I am really interested in knowing your numbers with your file. Please
if you decide to try it let me know how it goes. (or just post an
answer here) Remember to compile on release mode for the test, even
when that will not afect the results very much.

Hope this helps
Best regards,
Adrian.

Mar 29 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: OM | last post by:
How do I import excel data into 2 joined tables ? The data is fldDate, fldTruck, fldLitres, fldSpeedometer. fldDate goes in a table tblFuelHeader, and the rest goes in tblFuelDetail, with a...
1
by: Antonio. kim | last post by:
Hello~ ^^ I have a question about getting excel data with oledbconnection. I entered '23190000' to Excel Cell and changed Column width to small, then the value chaged to 2E+07 or ####. And I...
2
by: sunstarwu | last post by:
Hi, I am having difficultly being able to view certain Columns and rows via a DropDownList. Everytime I load my webpage.aspx it just shows empty drop down menus. I have no problem showing all...
0
by: sunilkumar Reddy via DotNetMonster.com | last post by:
hai all first we have taken binded grid Export to excel data from ultrawebgrid (or) datagrid rows, Each row data Expoting to one worksheet in excel workbook, like as grid row1 data contain...
1
by: Ramakrishnan Nagarajan | last post by:
Hi, I am converting Excel data into a Dataset in C#. There are around 24 columns in the Excel Sheet. First I tried to insert one row with correct values in the Excel sheet. i.e. for text columns...
1
by: ShailShin | last post by:
Hi All, I have to convert Excel data to MSAcess .MDB file using VB.NET. VB.NET Code read the Excel file and write it to .MDB file. For the same I have below code, but I am stuck at the writing it...
3
by: Bharathi Kumar | last post by:
Hi, In my windows application, I have created excel.application object and read the excel data. I saved the data to sql server also. The problem Iam facing is when I create an instance of...
10
by: Niklas | last post by:
Hi Before I start coding I need to be sure that nobody else has not done it yet and that I can use it. I need an import utility which import data from Excel to a database or some object in...
0
by: Grip | last post by:
Hi, I have gone throught the group and Microsoft's online help and have seen many suggestions but I am still seeking clarity: 1. I have an excel spreadsheet. Column A contains text that may...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.