Main Topics
Browse All TopicsIn Delphi 6.0 with Excel 8.0(2000)
How I can read(or write) a value (or field value) from(in)
workBook in cells of excell.
(How I can creat a relation with excel and delphi)
Thanks
best regards
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
A small demo programme that show almost everything you can do:
http://www.phidels.com/php
Sources and captions are pretty self explanatory but in French...
If your French is enough to understand "ouvrir", "lire", and "fermer" you should pretty much understand all of it.
Hope it helps:
Jack
OK, then this is about the way to go:
Get a new form.
Put an OleContainer in it, call it OleContainer1.
Put also a TExcelApplication, call it xlsAp.
Put a TExcelWorkbook. Call it xlsWB.
Put a TExcelWorksheet. Call it xlsWS.
Put an edit and button to open a file.
The click event handler should be something like:
procedure TForm1.Button6Click(Sender
var lcid: integer;
K, R, X, Y : Integer;
RangeMatrix : Variant;
begin
olecontainer1.CreateLinkTo
{ No need to start Excel ourselves, since the ExcelApplication's AutoConnect
property is True }
lcid := GetUserDefaultLCID;
xlsApp.Visible[lcid]:=true
xlsApp.Workbooks.Open(edit
{ To open a new file:
xlsWB.ConnectTo(xlsApp.Wor
xlsWB.ConnectTo(xlsApp.Wor
xlsWS.ConnectTo(xlsWB.Work
xlsWS.Activate;
xlsWS.Cells.SpecialCells(x
{ Some stuff you can do: }
// Get the value of the last row
X := xlsApp.ActiveCell.Row;
// Get the value of the last column
Y := xlsApp.ActiveCell.Column;
{ Lets say you also had a TStringGrid on the form:
StringGrid1.Cells[0,0]:= 'X: '+inttostr(X);
StringGrid1.Cells[1,0]:= 'Y: '+inttostr(Y);
StringGrid1.RowCount:= Y;
StringGrid1.ColCount:= Y;
R := StringGrid1.RowCount;
RangeMatrix := xlsApp.Range['A1',xlsApp.C
// Define the loop for filling in the TStringGrid
K := 1;
repeat
for R := 1 to Y do
StringGrid1.Cells[(R - 1),(K)] := RangeMatrix[K,R];
Inc(K,1);
StringGrid1.RowCount := K + 1;
until K > X;
}
// xlsWS.Range['A1','A1'].Val
{ Even more fun stuff: }
{
vMSExcel.ActiveWorkbook.Wo
vMSExcel.range['a2']:='11:
vMSExcel.Selection.EntireR
vMSExcel.ActiveCell.Formul
vMSExcel.Range['A2','b3'].
vMSExcel.Selection.Interio
}
end;
Just a warning: this is *sort of* the way to do it. But this code is probably flawed and will either not compile or raise exceptions. You will need to read some helps to get it to work, but I hope it wil put you on the right path. =)
Hope it helps.
Regards:
Jack
You want to have all the buttons and menu options of Excel in your app?
Something similar to what happens when you open an xls with Internet Explorer? (Or a pdf and you get an instance of Acrobat Reader running within IE).
I've never done that.
My guess is you do it with OLE Automation just like the last example but that you have to fiddle a little with the properties of the TOLEContainer.
The helps for TOLEContainer (for Delphi 5) mention the possibility of doing it. Here goes an excerpt from the description for the TOLEContainer. Reading about it's properties, methods and events should lead you where you're going in no time at all. (I hope...)
--------------------------
Description
Use TOleContainer to handle many of the complexities of OLE 2.0. TOleContainer lets the user choose an OLE object to insert by simply calling the InsertObjectDialog method. TOleContainer can create either an embedded OLE object or a linked OLE object.
TOleContainer automatically handles menu merging -- the process of combining the container form's menu with that of an in-place activated OLE object's server application. The menu items' GroupIndex property settings control how menus are merged. Those main menu items with GroupIndex values of 0, 2, and 4 remain; TOleContainer merges the server application's menus and replaces the main menu items with GroupIndex values of 1, 3, and 5 (if they exist).
OLE objects that are activated in-place add their servers' toolbars directly into the container application's window. Normally, any panels used for toolbars are replaced by the OLE object's server's toolbars. Prevent this by setting a panel's Locked property to True.
When using TOleContainer in an SDI application (the main form's FormStyle property is fsNormal rather than fsMDIForm), place the TOleContainer component inside a panel whose Align property is set to alClient. TOleContainer replaces an SDI form's toolbars as described above, and using a panel automatically adjusts the amount of space available to the OLE container.
--------------------------
If you still feel I haven't understood you correctly, you can mail me that image at <wgrillo@fi.uba.ar>
Regards:
Jack
uses word2000
const
FLCID = LOCALE_USER_DEFAULT;
....
function TExlApp.OpenWorkbook(AWork
ANewWorkbook: boolean = true): IXLWorkbook;
var
FIWorkbook := Workbooks.Add(TemplateDirP
if (Trim(AWorkbookPath) <> '') and not(ANewWorkbook) then
FIWorkbook := Workbooks.Open(AWorkbookPa
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, FLCID);
end;
procedure wirteExcel(WorkSheetName:s
var ISheet: _Worksheet
begin
ISheet:=FIWorkbook.Workshe
ISheet.Cells.Item[RowNum,C
end;
...
{you can use VBA like this,Hope it helps.}
Business Accounts
Answer for Membership
by: GloomyFriarPosted on 2003-10-28 at 08:54:16ID: 9635071
Use TExcelApplication from "Servers" tab.