Board index » cppbuilder » BCB5 and Excel

BCB5 and Excel


2007-07-17 05:49:24 AM
cppbuilder52
Hello Folks,
Have BCB 5.0 professional.
I would like to put data in certain positions of a excell worksheet.
Or, would like to make BCB 5 act like a spreadsheet if it will not put the
data in the MS excell.
i have tried playing with the Excell stuff on Borland Builder 5.0, but no
luck. Could some give me some hindsight on doing such things?
It is not a muli-sheet/page Work sheet, but only a single sheet/page
excell file.
Thanks
Dwayne
 
 

Re:BCB5 and Excel

"Dwayne" < XXXX@XXXXX.COM >wrote in message
Quote
Have BCB 5.0 professional.
I would like to put data in certain positions of a excell worksheet.
Or, would like to make BCB 5 act like a spreadsheet if it will not put the
data in the MS excell.
i have tried playing with the Excell stuff on Borland Builder 5.0, but no
luck. Could some give me some hindsight on doing such things?
It is not a muli-sheet/page Work sheet, but only a single sheet/page
excell file.
Write out a CSV file - rows with columns separated by commas. Then
ShellExecute it. It will start Excel and pump the data in. For example,
Write out :-
1,2,3
4,5,6
7,8,9
into mynew.csv
ShellExecute it. Excel will start up with cells populated as follows :-
A1 as 1
B1 as 2
C1 as 3
A2 as 4
B2 as 5
C2 as 6
A3 as 7
B3 as 8
C3 as 9
HTH,
--
Mark Jacobs
DK Computing
www.dkcomputing.co.uk
 

Re:BCB5 and Excel

Hello Mark,
Quote
Write out a CSV file - rows with columns separated by commas. Then
ShellExecute it. It will start Excel and pump the data in. For example,

Write out :-
1,2,3
4,5,6
7,8,9
into mynew.csv

ShellExecute it. Excel will start up with cells populated as follows :-
A1 as 1
B1 as 2
C1 as 3
A2 as 4
B2 as 5
C2 as 6
A3 as 7
B3 as 8
C3 as 9
Thank you very much for your time and answer.
Is it also possible to read the Cells itnto Borland BCB5?
Dwayne
 

{smallsort}

Re:BCB5 and Excel

"Dwayne" < XXXX@XXXXX.COM >wrote in message
Quote
Is it also possible to read the Cells itnto Borland BCB5?
Yes. You set the CommaText property of each row of a string grid to each row
of the CSV file. That would populate the string grid in the same way as an
Excel spreadsheet. If your CSV file was called "mycsv.csv" and you had a
maximum of 100 columns, then the following code would put it into a string
grid :-
Memo1->Lines->LoadFromFile("mycsv.csv");
StringGrid1->RowCount=Memo1->Lines->Count+2;
StringGrid1->ColCount=102;
// 2 is added to both dimensions to make room for a header row and a totals
row
for (int ii=0;ii<Memo1->Lines->Count;++ii)
StringGrid1->Rows[ii]->CommaText=Memo1->Lines->Strings[ii];
HTH,
--
Mark Jacobs
DK Computing
www.dkcomputing.co.uk