To write a XLS file using WPS CreateOleObject Ket.Application in Delphi, you can follow these steps:

  1. Open Delphi and create a new project.
  2. Add a button to the form.
  3. Double-click on the button to create an OnClick event handler.
  4. In the event handler, add the following code:
var
  Excel: OleVariant;
begin
  Excel := CreateOleObject('Ket.Application');
  Excel.Visible := True;
  Excel.Workbooks.Add;
  Excel.Worksheets[1].Cells[1,1] := 'Hello World!';
  Excel.ActiveWorkbook.SaveAs('C:\example.xls', 56);
  Excel.Quit;
end;
  1. This code will create a new instance of Excel using the CreateOleObject function. It will then make the Excel window visible and create a new workbook. It will then write the text "Hello World!" to cell A1 of the first worksheet. Finally, it will save the workbook to a file called "example.xls" on the C: drive and quit Excel.

Note: The number 56 in the SaveAs function represents the file format for XLS. You can find a list of file format codes in the Excel documentation

how to write a xls file use wps CreateOleObject KetApplication in delphi

原文地址: https://www.cveoy.top/t/topic/dHV8 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录