Thanks for your reply Patrick,
But if I read your code rightly, you've got methods for reading, writing and
clearing an Excel cell. What I am looking for is a way to return a *Range
Object* from the cells that have been written into ...
Once I've pumped the data into Excel, I need to convert that data into an
Excel Chart. Excel requires a Range Object to identify which cells to use
to create the chart. I'm expecting the code to look something like
ASHT := ER.OLEExcel.ActiveWorkbook.ActiveSheet;
RNGE := ASHT.Range(ASHT.Range.Cells(1,1), ASHT.Range.Cells(10,1)).Select;
(where ASHT and RNGE are of type OLEVariant) Except that this does not work
so maybe it looks quite different. :-)
So do you have any further pointers?
-----Original Message-----
From: Patrick Dunford <[EMAIL PROTECTED]>
To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
Date: Monday, 19 June 2000 07:09
Subject: RE: [DUG]: Talking to Excel.
I did some work with this for a customer several years ago and they are
still using that product. My recollection is of having problems similar to
what you describe. (See below) - note I am using Delphi 3, it didn't come
with TExcelReport
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of Michael Switzer
> Sent: Friday, 16 June 2000 16:35
> To: Multiple recipients of list delphi
> Subject: [DUG]: Talking to Excel.
>
>
> Hi all,
>
> I'm trying to get Delphi 4 to create a chart in Excel. Stop sniggering.
>
> Does anyone know how to get an Excel 'Range' object to work? The docs say
> it expects an argument of - in VB speak - ("A1:H8") so that it looks like
> ...Range("A1:H8")...
>
> So far my code does the following:
>
> <snip>
> ER := TExcelReport.Create; // ER.OLEExcel is the OLE automation
> object for
> the Excel Application
> <snip>
> ASHT := ER.OLEExcel.ActiveWorkbook.ActiveSheet;
> ASHT.Range('A1'); // error
> <snip>
>
> Variations on this error line (like below) don't work as far as I can see.
> ASHT.Range.Cells(1,1);
> ASHT.Range('"A1'");
> ASHT.Range(ASHT.Range.Cells(1,1), ASHT.Range.Cells(2,2)):
>
> My aim is to get back a range object that I can then use to help create my
> chart.
Not sure what you're trying to do. This is what our code does in order to
fill a range of cells (called in a For loop). At least it does work:
procedure TMainForm.WriteCellString(CRow,CCol:integer;Data:String);
begin
ExcelApp.Goto('R'+IntToStr(CRow)+'C'+IntToStr(CCol));
ExcelApp.ActiveCell.Value:=Data;
end;
procedure TMainForm.ReadCellString(CRow,CCol:integer; var Data:string);
//[1.33+]
var D:OleVariant;
begin
ExcelApp.Goto('R'+IntToStr(CRow)+'C'+IntToStr(CCol));
D:=ExcelApp.ActiveCell.Value;
Data:=String(D);
end;
procedure TMainForm.ClearCell(CRow,CCol:integer);
begin
ExcelApp.Goto('R'+IntToStr(CRow)+'C'+IntToStr(CCol));
ExcelApp.ActiveCell.ClearContents;
end;
ExcelApp is an object created and assigned as follows (Delphi 3) :
ExcelApp:=CreateOLEObject('Excel.Application');
***OR***
ExcelApp:=GetActiveOLEObject('Excel.Application');
ExcelApp.Workbooks.Open('SomeFileName',0,False);
ExcelApp.ActiveWorkbook.Worksheets.Item(1).Activate;
after which we are ready to read or write cells using the code above.
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz