472,789 Members | 1,083 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,789 software developers and data experts.

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 9069
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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.