Link to home
Start Free TrialLog in
Avatar of hussamd
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]:=True;

  { Create a new workbook }
  { The TOleEnum cast in the next line just prevents compiler range warnings }
  WkBk.ConnectTo(ExcelApplication1.Workbooks.Add(TOleEnum(xlWBATWorksheet), lcid));
  WS.ConnectTo(WkBk.Worksheets[1] as _Worksheet);
  WS.Name := 'Data';
  EnterData;
end;
the error message is(old format or invalid type library)
Avatar of Mohammed Nasman
Mohammed Nasman
Flag of Palestine, State of image

Hello

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
You can also do it without Excel:

http://www.wotsit.org/download.asp?f=xls
Try this:
LCID:=LOCALE_USER_DEFAULT
FExcelApplication.ConnectKind:=ckNewInstance;
FExcelApplication.Connect;
FExcelWorkbook.ConnectTo(FExcelApplication.Workbooks.Add(TOleEnum(xlWBATWorksheet),LCID));
FExcelWorksheet.ConnectTo(FExcelWorkbook.Worksheets[1] as _Worksheet)
.
.
.
FExcelWorksheet.Name:='name';
.
.
FExcelApplication.Visible[LCID]:=True/False;
FExcelApplication.ScreenUpdateing[LCID]:=True/False;
FExcelApplication.displayAlerts[LCID]:=True/False;
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
ASKER CERTIFIED SOLUTION
Avatar of PashaMod
PashaMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial