Jump to content

Recommended Posts

Posted
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;
 
 
 

 

Posted

Dear Hayri, 

 

which mode working your application? 

 

the real problem in this  Excel:= CreateOleObject('Excel.Application'); 

Cannot create excel ole.

Posted

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
  • 2 weeks later...
  • 3 weeks later...
Posted

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');
  • 8 months later...
Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...