hussamd
asked on
how to create excel file by delphi
hi ihave aproblem with the servers component in delphi the procedure below should open excel97 but it doesn't do
so,i'm running excel2000.
{ No need to start Excel ourselves, since the ExcelApplication's AutoConnect
property is True }
lcid := GetUserDefaultLCID;
ExcelApplication1.Visible[ lcid]:=Tru e;
{ Create a new workbook }
{ The TOleEnum cast in the next line just prevents compiler range warnings }
WkBk.ConnectTo(ExcelApplic ation1.Wor kbooks.Add (TOleEnum( xlWBATWork sheet), lcid));
WS.ConnectTo(WkBk.Workshee ts[1] as _Worksheet);
WS.Name := 'Data';
EnterData;
end;
the error message is(old format or invalid type library)
so,i'm running excel2000.
{ No need to start Excel ourselves, since the ExcelApplication's AutoConnect
property is True }
lcid := GetUserDefaultLCID;
ExcelApplication1.Visible[
{ Create a new workbook }
{ The TOleEnum cast in the next line just prevents compiler range warnings }
WkBk.ConnectTo(ExcelApplic
WS.ConnectTo(WkBk.Workshee
WS.Name := 'Data';
EnterData;
end;
the error message is(old format or invalid type library)
Try this:
LCID:=LOCALE_USER_DEFAULT
FExcelApplication.ConnectK ind:=ckNew Instance;
FExcelApplication.Connect;
FExcelWorkbook.ConnectTo(F ExcelAppli cation.Wor kbooks.Add (TOleEnum( xlWBATWork sheet),LCI D));
FExcelWorksheet.ConnectTo( FExcelWork book.Works heets[1] as _Worksheet)
.
.
.
FExcelWorksheet.Name:='nam e';
.
.
FExcelApplication.Visible[ LCID]:=Tru e/False;
FExcelApplication.ScreenUp dateing[LC ID]:=True/ False;
FExcelApplication.displayA lerts[LCID ]:=True/Fa lse;
where FExcelApplication is instance of TExcelApplication
and FExcelWorkbook is instance of TExcelWorkbook
and FExcelWorksheet is instance of TExcelWorksheet
ziolko.
LCID:=LOCALE_USER_DEFAULT
FExcelApplication.ConnectK
FExcelApplication.Connect;
FExcelWorkbook.ConnectTo(F
FExcelWorksheet.ConnectTo(
.
.
.
FExcelWorksheet.Name:='nam
.
.
FExcelApplication.Visible[
FExcelApplication.ScreenUp
FExcelApplication.displayA
where FExcelApplication is instance of TExcelApplication
and FExcelWorkbook is instance of TExcelWorkbook
and FExcelWorksheet is instance of TExcelWorksheet
ziolko.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
To be PAQ/Refund
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
Thank you,
Russell
EE Cleanup Volunteer
I will leave a recommendation in the Cleanup topic area that this question is:
To be PAQ/Refund
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
Thank you,
Russell
EE Cleanup Volunteer
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Look at this page, it will help you alot to connect excel from delphi
http://www.djpate.freeserve.co.uk/AutoExcl.htm
Best regards
Mohammed