473,748 Members | 2,223 Online
Bytes | Software Development & Data Engineering Community
+ 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 9135
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.co m

"Peter" <pc*****@nospam .nospam> wrote in message
news:uH******** *****@TK2MSFTNG P15.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.c om> wrote in
message news:ej******** ******@TK2MSFTN GP09.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.co m

"Peter" <pc*****@nospam .nospam> wrote in message
news:uH******** *****@TK2MSFTNG P15.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.XlsAdap ter;

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

private void button1_Click(o bject sender, System.EventArg s e)
{
DateTime StartTime = DateTime.Now;
XlsFile xls = new XlsFile(true);
xls.Open("tooma nycells.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.ColCountInR ow(r); cindex > 0;
cindex--)
{
int c = xls.ColFromInde x(r, cindex);
int XF = 0;
object o = xls.GetCellValu eIndexed(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.Resul t;
}
}

}
}
}
DateTime EndTime = DateTime.Now;

MessageBox.Show ((EndTime - StartTime).ToSt ring());

}
}
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.ToDoubl e
method - that's what was slowing it down.

I do like your control and I will buy it.

"Adrian Gallero" <ag***********@ SPAMnetscape.ne t> wrote in message
news:eD******** ******@TK2MSFTN GP12.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.XlsAdap ter;

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

private void button1_Click(o bject sender, System.EventArg s e)
{
DateTime StartTime = DateTime.Now;
XlsFile xls = new XlsFile(true);
xls.Open("tooma nycells.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.ColCountInR ow(r); cindex > 0;
cindex--)
{
int c = xls.ColFromInde x(r, cindex);
int XF = 0;
object o = xls.GetCellValu eIndexed(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.Resul t;
}
}

}
}
}
DateTime EndTime = DateTime.Now;

MessageBox.Show ((EndTime - StartTime).ToSt ring());

}
}
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
4532
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 one to many relationship between tblFuelHeader and tblFuelDetail. I have a lot of legacy data, and no desire to type it all in. Any help greatfully received, seized upon, and used immediately.
1
1720
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 saved this file...(maybe both data saved..viewed data and original data) when openning this file with oledbconnection, I got '2E+07' without original data '23190000'. I'd want to get original data '23190000' instead of viewed data like '2E+07',...
2
5584
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 the Excel data in a DataGrid, its just DropDownLists. To view all the data in a DataGrid I just followed the instructions on
0
1740
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 sheet1 grid row2 data contain sheet2 grid row3 data contain sheet3 we have pressing one button ultrawebgrid (or) datagrid rows data to export
1
2645
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 I entered text values and for numeric columns I entered numeric values. It works fine and pass through all the validation checks and gets inserted into the database successfully. But when I gave some junk values in the excel sheet and tried to...
1
11371
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 to .MDB file. which I have already created with Table as Terms which contains 10 Fields and my Excel contains 10 Fields, Here I want to Extract 3 columns data from Excel to Table. Also it shows error of "syntax error in INSERT INTO Command. ...
3
1613
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 excel.application object, Microsoft excel process is being created and it stays though I terminate the application. I gave an input excel file, the problem has read the contents of that file........
10
11826
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 .NET. The data in Excel is not in structured columns but can exist everywhere in the workbook. For example if I am supposed to import a person and all his/her cars which exist in a workbook I want to be able to create an import protocol and specify...
0
14420
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 be greater than 255 characters. 2. I have an access database. I link (not import) to the contents of the excel spreadsheet. In the design view in access, Column A has the data type "memo".
0
8822
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9359
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9310
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8235
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6072
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4592
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3298
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.