Jump to content

Excel Export Problem in ISAPI mode


iyarar

Recommended Posts

Hi,

I am using the following code to export data to excel. 

But this code is working in vcl and standalone server mode, does not work in isapi mode.

 

I need the code to work  in ISAPI mode. Do you have any idea for help me ?

 

 
var
  Excel, wSheet: Variant;
  i,j:integer;
  s,Fl:string;
Begin
  If Myq_Report.RecordCount>0 Then
  Begin
 
    try
       Excel:= CreateOleObject('Excel.Application');
    except
      Exit;
    end;
 
    Excel.Visible := False;
    Excel.Workbooks.Add;
    wSheet:= Excel.WorkBooks[1].WorkSheets[1];
    wSheet.Cells[2,1]  := 'Company';
    wSheet.Cells[2,1].Columns.ColumnWidth:=20;
    wSheet.Cells[2,2]  := 'Date';
    wSheet.Cells[2,2].Columns.ColumnWidth:=10;
    wSheet.Cells[2,3]  := 'Time';
    wSheet.Cells[2,3].Columns.ColumnWidth:=5;
 
    wSheet.Cells[1,1]:='SERVICE LIST';
    wSheet.Rows[1].RowHeight := 20;
    wSheet.Rows[1].Font.Size := 14;
    wSheet.Rows[1].Font.Color:=ClWhite;
    wSheet.Range['A1:R1'].Mergecells:=True;
    wSheet.Range['A1:R1'].Interior.ColorIndex:=16;
    wSheet.Range['A1:R1'].HorizontalAlignment := -4108;
    wSheet.Range['A1:R1'].VerticalAlignment   := -4108;
 
 
    Fl:='servicelist_'+FormatDateTime('YYMMDDhhmmnnss',now)+'.xls';
    wSheet.SaveAs(UniServerModule.LocalCachePath+Fl);
    s := UniServerModule.LocalCacheURL;
    s := StringReplace(s,'\','/',[rfReplaceAll]);
    UniURLFrame1.URL := s+fl;
    Excel.quit;
 End;
End;
 
 
 

 

Link to comment
Share on other sites

dear agmoro7622 

 

we can create and send to xls or csv to user. 

it is possible

 

Hi,

 

it is true that you can create xls third component, but not CreateOleObject ('Excel.Application') in ISAPI mode.

 

I have the same problem and yet discard CreateOleObject.
 
Regards
Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...

Use FastReport - works perfect!

 

FastReport excel export not working for me on ISAPI Mode

 

  frxXLSExport1.showprogress := false;

  frxXLSExport1.showdialog := false;

  frxReport1.PrepareReport();
  CreateGUID(NewGUID);
  frxXLSExport1.FileName := UniServerModule.TempFolderPath  + GUIDToString(NewGUID) + '.xls';
  frxReport1.Export(frxXLSExport1);
  UniSession.SendFile(UniServerModule.TempFolderPath + GUIDToString(NewGUID) + '.xls', 'export.xls');
  DeleteFile(UniServerModule.TempFolderPath + GUIDToString(NewGUID) + '.xls');
Link to comment
Share on other sites

  • 8 months later...

Hi freelancer,

Your code works for me, without your NewGUID lines, excel file is generated (as Zam said) from FastReports 5 on D2006 and Zeos.

Excel file is generated and downloaded normally to: http://localhost:8077/cache/MyApp/3o6eaeHm2CalYOd/$$$/export.xlsx

 

  frxXLSXExport1.showprogress := false;

  frxXLSXExport1.showdialog := false;
  frxReport1.PrepareReport();
  //CreateGUID(NewGUID);
  frxXLSXExport1.FileName := UniServerModule.TempFolderPath  + '.xlsx';
  frxReport1.Export(frxXLSXExport1);
  UniSession.SendFile(UniServerModule.TempFolderPath + '.xlsx', 'export.xlsx');

 

What is the CreateGUID for?

I'm using self server, not a dll, probably this is the issue?

Only changed XLS to a XLSX export, but I assume work to a XLS file too, regards.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...