Forum Discussion

MarinaB's avatar
MarinaB
Occasional Contributor
7 years ago

export data to excel file (Delphi)

Hi,   Anybody have example Delphi script for Export data to excel file.   I could find example at support.smartbear.com.  Thanks.
  • mikakoistinen's avatar
    7 years ago

    More specific question would always give better answers, but if you are looking for tools to write general data to xls file

    here is one example.

     

    procedure exceldemo;
    var  
      app, book,sheet;
      fn,row,col;
    begin
      fn := 'c:\temp\foo.xlsx';
      app := Sys.OleObject('Excel.Application');
      if aqFile.Exists(fn) then
        book := app.workbooks.open(fn)
      else       
        book := app.Workbooks.Add();
      sheet := book.sheets(1);
      
      app.DisplayAlerts := false;
      for row := 1 to 10 do
      begin
        for col :=1 to 10 do
        begin
          sheet.cells(row, col) := row * col;
        end;
      end;  
      book.SaveAs(fn);
      app.Quit(); 
    end;