Eden Posted December 8, 2011 Posted December 8, 2011 My sample code in TUniButton.OnClick: var ExcelApp: Variant; try ExcelApp := CreateOleObject('Excel.Application'); except ShowMessage('Not Found Excel!'); end; I have install Excel in my PC. But, always show except in Run-Time. Why? Quote
andersa@ellenshoej.dk Posted December 8, 2011 Posted December 8, 2011 How do you expect this to work? Is the intention that you click on a button in your browser and then excel opens? That will not work. Your browser can not open excel. If that was possible, any web site that you visited would be able to open excel on your computer. That would be a major security vulnerability. Maybe I am misunderstanding what it is you are trying to do. Quote
zilav Posted December 8, 2011 Posted December 8, 2011 I suppose he just wants to work with Excel files through web interface. Try to set ServerModule.AutoCoInitialize = True Quote
dionel1969 Posted December 8, 2011 Posted December 8, 2011 I suppose he just wants to work with Excel files through web interface. Try to set ServerModule.AutoCoInitialize = True If it is the Excel who works as a program in a Windows OS, it will never run over web interface as he is expecting. WEB Browser is a process running on a Client machine, and the file compiled with Delphi using UNIGUI is running as a Server Process runinng on a diferente machine called Server too. Also, when they are running in the same machine web browser is still a client process and the programa/dll, whatever, is still a server module, that run in a separate server process. So, when you call some actions from browsers, clicking on buttos, etc... by general rule, the result is reflected in the client process by the http request/response mechanism. Excel, the normal excel installed before 10 version is a local program, it could be works a server process and may be embebbed and/or linked into applications running in the same machine, or in other machine using Microsoft DCOM, OLE and other mechanism, no by using HTTP mechanism. You can embebbed Excel into your application, but how to send back to client browser the things is drawing in the interface of embbebed process???? It must be something to do that, to send client through http the excel interface and then you will able to use it. Quote
Eden Posted December 9, 2011 Author Posted December 9, 2011 My original workflow (Win32): 1. Client open excel file. 2. Import the excel file to database(dbx). 3. over. I want convert the project to Unigui. My Unigui workflow: 1. Client upload Excel file to Server. 2. Server will prcess excel import to Database(dbx); 3. Delete the Excel file in Server Below my simple code: procedure TfmMain.UniFileUpload1Completed(Sender: TObject; AStream: TFileStream); var DestName : string; DestFolder : string; begin DestFolder:=UniServerModule.StartPath+'UploadFolder\'; DestName:=DestFolder+ExtractFileName(UniFileUpload1.FileName); CopyFile(PChar(AStream.FileName), PChar(DestName), False); edtFilePath.Text := DestFolder + UniFileUpload1.FileName; end; procedure TfmMain.UniBtnFileUpload(Sender:TObject); begin UniFileUpload1.Filter := 'Excel files (*.xls)|*.xls'; UniFileUpload1.Execute; end; procedure TfmMain.UniBtnFileProcessClick(Sender: TObject); var MsExcel, MsExcelWorkBook, MsExcelWorkSheet: Variant; begin try MsExcel := CreateOleObject('Excel.Application'); except ShowMessage('Not Found Excel'); Exit; end; MsExcelWorkBook := msExcel.Workbooks.Open(edtFilePath.Text,0,EmptyParam,EmptyParam, EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam, EmptyParam,EmptyParam,EmptyParam,1,0); MsExcelWorkSheet := MsExcelWorkBook.WorkSheets[5]; ProcedureExcel(MsExcelWorkSheet); end; >>You can embebbed Excel into your application... I try embebbed Excel(NativeExcel) in my project. But, it don't work. My workflow is abnormal? Please, Help me! Thank you! Quote
zilav Posted December 9, 2011 Posted December 9, 2011 My workflow is abnormal? Please, Help me! Thank you! No, it is normal. Just make sure you have an Excel installed on the server where you suppose to run your unigui application. I've made a demo for you, it works fine on my Win7x64 with Office 2003 (I hate ribbon interface). UniGUIExcel.zip Quote
dionel1969 Posted December 9, 2011 Posted December 9, 2011 No, it is normal. Just make sure you have an Excel installed on the server where you suppose to run your unigui application. I've made a demo for you, it works fine on my Win7x64 with Office 2003 (I hate ribbon interface). That's what I said. You use a UniMemo as a "bridge" for showing the content of file in the client's browser from server. Anyway see these links: http://datawiz.wordpress.com/2011/01/10/how-to-embed-excel-on-a-web-page/ http://office.microsoft.com/en-us/web-apps-help/embed-an-excel-workbook-on-a-web-page-HA102029502.aspx http://labnol.blogspot.com/2006/09/embed-interactive-excel-spreadsheets.html Quote
zilav Posted December 9, 2011 Posted December 9, 2011 That's what I said. You use a UniMemo as a "bridge" for showing the content of file in the client's browser from server. Either my english is bad, or yours, because I don't understand what are you talking about. The request was to allow users to upload excel files and import them in database, noone is talking about showing them in browser. I even read his question again and still can't notice anything considering "show": 1. Client open excel file. 2. Import the excel file to database(dbx). 3. over. I think "over" means "the end", not "output". Don't have anything else to say because english is not my native language and probably I got his question wrong. p.s. And yes, you can't show excel files in browser until your render it in html (either yourself or with third party tools) or user uses some sort of embedded Excel ActiveX in web page, which is very unlikely. Quote
Eden Posted December 10, 2011 Author Posted December 10, 2011 No, it is normal. Just make sure you have an Excel installed on the server where you suppose to run your unigui application. I've made a demo for you, it works fine on my Win7x64 with Office 2003 (I hate ribbon interface). Yes! You are right! This test project can running in my PC! Very nice!!! Just because "ServerModule.AutoCoInitialize = True"? I will try it! Thank you! Quote
dionel1969 Posted December 10, 2011 Posted December 10, 2011 Either my english is bad, or yours, because I don't understand what are you talking about. The request was to allow users to upload excel files and import them in database, noone is talking about showing them in browser. I even read his question again and still can't notice anything considering "show": I think "over" means "the end", not "output". Don't have anything else to say because english is not my native language and probably I got his question wrong. p.s. And yes, you can't show excel files in browser until your render it in html (either yourself or with third party tools) or user uses some sort of embedded Excel ActiveX in web page, which is very unlikely. It is my English which is very bad. Ok, I re-read the question and I understand now what about. Thank you for your clarification. I promise to read slowly next time to understand deeply the topic. I just pass over the topic and saw the creation of OLE variant and make a mistake, caused I saw in the past more than once people trying to show excel, words, powerpoint files through the network like they do in Delphi applications. Ok, I repeat, it is my English first which is bad, and second I did not read the topic slowly to understand correctly the question about. So accept my apologies for leave out of the topic. 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.