Board index » delphi » Exporting data from string grid to excel

Exporting data from string grid to excel

See my note dated 4/5/1999 regarding "Accessing multiple values from
Excel..."

Basically, you can create a variant array and just assign it to an Excel
spreadsheet.
This works great for situations like yours because you can plow into Excel
huge amounts of data quickly.

Let me know how it goes.

Kevin

Adnan Zaman <AdnanZa...@aol.com> wrote in article
<7gp4mp$9...@forums.borland.com>...
how can i export data from a string grid to an excel spreadsheet on a row
by row basis?

right now i have to do it on a cell by cell basis. that is, i have the
following code to do this:

for rows:=1 to mygrid.rowcount-1 do
for cols:=1 to mygrid.colcount-1 do
{
    read and transfer the values to excel spreadsheet

Quote
}

as obvious to every one, this code would be drastically slow if i have to
export more than 10,000 rows from string grid.

i was thinking of using the rows property of string grid so that i would be
able to do my scan in just one loop. but the problem is that i don't know
how to do it?

can anyone help me out here?

by the way i already checked the previous posts and was able to find just
one such post containing something like:
sheetvariant.selection.insert.entirerow (the problem is that this is a VB
way of doing it and despite some tweakings i am still unable to make it
work).

thanx
Adnan.

----------

 

Re:Exporting data from string grid to excel


hi,

thanx for the tip.

i did read your post about accessing multiple values from excel spreadsheet
but how do u assign a variant array to the worksheet? can u provide me some
sample code?

second thing is that how can i find the functions that are associated with
an excel object?

third thing is that how would u such a thing in COM?

thanx
Adnan.

Quote
----- Original Message -----
From: Kevin Watts <watt...@teleport.com>

Newsgroups: borland.public.delphi.oleautomation
Sent: Wednesday, May 05, 1999 11:17 AM
Subject: Re: Exporting data from string grid to excel

> See my note dated 4/5/1999 regarding "Accessing multiple values from
> Excel..."

> Basically, you can create a variant array and just assign it to an Excel
> spreadsheet.
> This works great for situations like yours because you can plow into Excel
> huge amounts of data quickly.

> Let me know how it goes.

> Kevin

> Adnan Zaman <AdnanZa...@aol.com> wrote in article
> <7gp4mp$9...@forums.borland.com>...
> how can i export data from a string grid to an excel spreadsheet on a row
> by row basis?

> right now i have to do it on a cell by cell basis. that is, i have the
> following code to do this:

> for rows:=1 to mygrid.rowcount-1 do
> for cols:=1 to mygrid.colcount-1 do
> {
>     read and transfer the values to excel spreadsheet
> }

> as obvious to every one, this code would be drastically slow if i have to
> export more than 10,000 rows from string grid.

> i was thinking of using the rows property of string grid so that i would
be
> able to do my scan in just one loop. but the problem is that i don't know
> how to do it?

> can anyone help me out here?

> by the way i already checked the previous posts and was able to find just
> one such post containing something like:
> sheetvariant.selection.insert.entirerow (the problem is that this is a VB
> way of doing it and despite some tweakings i am still unable to make it
> work).

> thanx
> Adnan.

> ----------

Kevin Watts <watt...@teleport.com> wrote in message
news:01be9712$d079c7c0$1403a8c0@kevin-watts...
> See my note dated 4/5/1999 regarding "Accessing multiple values from
> Excel..."

> Basically, you can create a variant array and just assign it to an Excel
> spreadsheet.
> This works great for situations like yours because you can plow into Excel
> huge amounts of data quickly.

> Let me know how it goes.

> Kevin

> Adnan Zaman <AdnanZa...@aol.com> wrote in article
> <7gp4mp$9...@forums.borland.com>...
> how can i export data from a string grid to an excel spreadsheet on a row
> by row basis?

> right now i have to do it on a cell by cell basis. that is, i have the
> following code to do this:

> for rows:=1 to mygrid.rowcount-1 do
> for cols:=1 to mygrid.colcount-1 do
> {
>     read and transfer the values to excel spreadsheet
> }

> as obvious to every one, this code would be drastically slow if i have to
> export more than 10,000 rows from string grid.

> i was thinking of using the rows property of string grid so that i would
be
> able to do my scan in just one loop. but the problem is that i don't know
> how to do it?

> can anyone help me out here?

> by the way i already checked the previous posts and was able to find just
> one such post containing something like:
> sheetvariant.selection.insert.entirerow (the problem is that this is a VB
> way of doing it and despite some tweakings i am still unable to make it
> work).

> thanx
> Adnan.

> ----------

Re:Exporting data from string grid to excel


What I did is make use of the clipboard. Before, I get the a cell content
and assign it to my CustomGrid. But it is so slooow.
here is an excerpt from my implementation:
var
   wb,ws,Source:Variant;
begin
   source:= createOleObject('Excel.Application');
   try
     wb:=source.Workbooks.open((szFromFile));
     ws := wb.sheets[1];
     ws.Range[ws.Cells[1,1],ws.Cells[n,k]].Copy;   {to clipboard}
     //
     // Parse the clipboard here.
     // The clipboard's content is of type TEXT. each column is delimited by
a tab and row by CRLF chars.
     //
   finally
      source.quit;
      source := unassigned;
   end;
end;

Quote
Adnan Zaman wrote in message <7h1hec$h...@forums.borland.com>...

>hi,

>thanx for the tip.

>i did read your post about accessing multiple values from excel spreadsheet
>but how do u assign a variant array to the worksheet? can u provide me some
>sample code?

>second thing is that how can i find the functions that are associated with
>an excel object?

>third thing is that how would u such a thing in COM?

>thanx
>Adnan.

>----- Original Message -----
>From: Kevin Watts <watt...@teleport.com>
>Newsgroups: borland.public.delphi.oleautomation
>Sent: Wednesday, May 05, 1999 11:17 AM
>Subject: Re: Exporting data from string grid to excel

>> See my note dated 4/5/1999 regarding "Accessing multiple values from
>> Excel..."

>> Basically, you can create a variant array and just assign it to an Excel
>> spreadsheet.
>> This works great for situations like yours because you can plow into
Excel
>> huge amounts of data quickly.

>> Let me know how it goes.

>> Kevin

>> Adnan Zaman <AdnanZa...@aol.com> wrote in article
>> <7gp4mp$9...@forums.borland.com>...
>> how can i export data from a string grid to an excel spreadsheet on a row
>> by row basis?

>> right now i have to do it on a cell by cell basis. that is, i have the
>> following code to do this:

>> for rows:=1 to mygrid.rowcount-1 do
>> for cols:=1 to mygrid.colcount-1 do
>> {
>>     read and transfer the values to excel spreadsheet
>> }

>> as obvious to every one, this code would be drastically slow if i have to
>> export more than 10,000 rows from string grid.

>> i was thinking of using the rows property of string grid so that i would
>be
>> able to do my scan in just one loop. but the problem is that i don't know
>> how to do it?

>> can anyone help me out here?

>> by the way i already checked the previous posts and was able to find just
>> one such post containing something like:
>> sheetvariant.selection.insert.entirerow (the problem is that this is a VB
>> way of doing it and despite some tweakings i am still unable to make it
>> work).

>> thanx
>> Adnan.

>> ----------

>Kevin Watts <watt...@teleport.com> wrote in message
>news:01be9712$d079c7c0$1403a8c0@kevin-watts...
>> See my note dated 4/5/1999 regarding "Accessing multiple values from
>> Excel..."

>> Basically, you can create a variant array and just assign it to an Excel
>> spreadsheet.
>> This works great for situations like yours because you can plow into
Excel
>> huge amounts of data quickly.

>> Let me know how it goes.

>> Kevin

>> Adnan Zaman <AdnanZa...@aol.com> wrote in article
>> <7gp4mp$9...@forums.borland.com>...
>> how can i export data from a string grid to an excel spreadsheet on a row
>> by row basis?

>> right now i have to do it on a cell by cell basis. that is, i have the
>> following code to do this:

>> for rows:=1 to mygrid.rowcount-1 do
>> for cols:=1 to mygrid.colcount-1 do
>> {
>>     read and transfer the values to excel spreadsheet
>> }

>> as obvious to every one, this code would be drastically slow if i have to
>> export more than 10,000 rows from string grid.

>> i was thinking of using the rows property of string grid so that i would
>be
>> able to do my scan in just one loop. but the problem is that i don't know
>> how to do it?

>> can anyone help me out here?

>> by the way i already checked the previous posts and was able to find just
>> one such post containing something like:
>> sheetvariant.selection.insert.entirerow (the problem is that this is a VB
>> way of doing it and despite some tweakings i am still unable to make it
>> work).

>> thanx
>> Adnan.

>> ----------

Other Threads