iyarar Posted December 24, 2013 Posted December 24, 2013 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; Quote
heromo80 Posted December 24, 2013 Posted December 24, 2013 Hi, it is not possible server-side Automation of Office http://support.microsoft.com/kb/257757 Quote
Hayri ASLAN Posted December 24, 2013 Posted December 24, 2013 dear agmoro7622 we can create and send to xls or csv to user. it is possible Quote
iyarar Posted December 24, 2013 Author Posted December 24, 2013 Dear Hayri, which mode working your application? the real problem in this Excel:= CreateOleObject('Excel.Application'); Cannot create excel ole. Quote
heromo80 Posted December 26, 2013 Posted December 26, 2013 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 Quote
Administrators Farshad Mohajeri Posted December 26, 2013 Administrators Posted December 26, 2013 Use a 3rd party excel export component such as Flexcel. Quote
billyChou Posted January 3, 2014 Posted January 3, 2014 Hi, SMExport http://www.scalabium.com/ Regards Quote
iyarar Posted January 8, 2014 Author Posted January 8, 2014 Hi, Thanks for your advice. I prefer Flexcel . It's working perfect. Quote
freelancer Posted January 24, 2014 Posted January 24, 2014 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'); Quote
joriolm Posted October 7, 2014 Posted October 7, 2014 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.