55143681 Posted August 19, 2018 Share Posted August 19, 2018 I want to open a SaveFileDialog to select a path and set the file name,but when I use SaveDialog,It will display in the server,not in the client,How can I open a file savedialog in the client PC or the browser? Quote Link to comment Share on other sites More sharing options...
asapltda Posted August 19, 2018 Share Posted August 19, 2018 Send file to Client ------------------------ procedure TFCONSULTAMOVINVENTARIOS.BTN_DownLoadXLSClick(Sender: TObject); var Uid: TGuid; Result: HResult; W_recurso :string; w_FileName :string; FilesFolderPath:string; TempFolderPath :string; ExtFullPath :string; w_Ruta :string; ExcelName :string; begin ExtFullPath := UniServerModule.ExtFullPath ; // CREATE GUID PARA MANEJO DE ARCHIVO DE DATOS Result := CreateGuid(Uid); CreateGuid(Uid); if Result = 1 then w_FileName:= GuidToString(Uid) ; // ARMAR NOMBRE DE ARCHIVO PARA ENVIA AL FOLDER TEMPORAL // W_recurso := RECURSO.Text; w_FileName:= w_FileName + '.xls' ; w_Ruta := UniServerModule.TempFolderPath + w_FileName ; // CONVERTIR ARCHIVO A EXCEL , SALVARLO TEMPORALMENTE Y CREAR LINK DE DESCARGA uNativeXLSExport.DataSetToXLS(INMOV, w_Ruta ); UniSession.SendFile(w_Ruta , 'MovInventory.xls'); LnkDowlaod.Caption:='<a href="'+ w_Ruta +'" target=new>Click here to download: ( '+' MovInventory.xls'+')</a>'; LnkDowlaod.SetFocus; end; Quote Link to comment Share on other sites More sharing options...
55143681 Posted August 20, 2018 Author Share Posted August 20, 2018 Send file to Client ------------------------ procedure TFCONSULTAMOVINVENTARIOS.BTN_DownLoadXLSClick(Sender: TObject); var Uid: TGuid; Result: HResult; W_recurso :string; w_FileName :string; FilesFolderPath:string; TempFolderPath :string; ExtFullPath :string; w_Ruta :string; ExcelName :string; begin ExtFullPath := UniServerModule.ExtFullPath ; // CREATE GUID PARA MANEJO DE ARCHIVO DE DATOS Result := CreateGuid(Uid); CreateGuid(Uid); if Result = 1 then w_FileName:= GuidToString(Uid) ; // ARMAR NOMBRE DE ARCHIVO PARA ENVIA AL FOLDER TEMPORAL // W_recurso := RECURSO.Text; w_FileName:= w_FileName + '.xls' ; w_Ruta := UniServerModule.TempFolderPath + w_FileName ; // CONVERTIR ARCHIVO A EXCEL , SALVARLO TEMPORALMENTE Y CREAR LINK DE DESCARGA uNativeXLSExport.DataSetToXLS(INMOV, w_Ruta ); UniSession.SendFile(w_Ruta , 'MovInventory.xls'); LnkDowlaod.Caption:='<a href="'+ w_Ruta +'" target=new>Click here to download: ( '+' MovInventory.xls'+')</a>'; LnkDowlaod.SetFocus; end; THANKS,I will my user can select where to save the file and can set the file name.and I know how to download the file. Quote Link to comment Share on other sites More sharing options...
Wilton Ergon Posted August 21, 2018 Share Posted August 21, 2018 could share uNativeXLSExport function Quote Link to comment Share on other sites More sharing options...
Oliver Morsch Posted August 21, 2018 Share Posted August 21, 2018 THANKS,I will my user can select where to save the file and can set the file name.and I know how to download the file. You can only initiate a download. File save dialog depends on browser setting. In Chrome there is no option for this, other browsers have it. Quote Link to comment Share on other sites More sharing options...
55143681 Posted August 23, 2018 Author Share Posted August 23, 2018 You can only initiate a download. File save dialog depends on browser setting. In Chrome there is no option for this, other browsers have it. I wish my customers can select where to save file he want before download from server,I have put a saveDialog in the form,but when the the saveDialog is executed ,it display in the server ,not in the browser. Quote Link to comment Share on other sites More sharing options...
55143681 Posted August 23, 2018 Author Share Posted August 23, 2018 could share uNativeXLSExport function I use flexCel to download excel files,you should first produce the file in the server side,then download it. //--------------------------------------------------------------------------- void __fastcall TUniFormFreeQuery::UniBitBtn10Click(TObject *Sender) { TExcelFile *xls = new TXlsFile(true); __try { saveToExcel(xls); } __finally { delete xls; } } //--------------------------------------------------------------------------- void __fastcall TUniFormFreeQuery::saveToExcel(TExcelFile *xls) { AnsiString destPath,destFile,tempFile; int rowCount,colCount,i,j; if(!UniQuery1->Active) { ShowMessage("先查询,再导出!"); return; } if(UniQuery1->RecordCount<1) { ShowMessage("没有记录,取消导出!"); return; } // xls->NewFile(1); rowCount=UniQuery1->RecordCount; colCount=UniQuery1->FieldCount; //写列头 i=1; for(j=1;j<colCount;j++) { xls->SetCellValue(i, j, TCellValue::Create(UniQuery1->Fields->FieldByNumber(j)->FieldName)); } //写数据 i=2; while(!UniQuery1->Eof) { for(j=1;j<colCount;j++) { xls->SetCellValue(i, j, TCellValue::Create(UniQuery1->Fields->FieldByNumber(j)->AsString)); } UniQuery1->Next(); i++; } xls->PrintLandscape = true; tempFile="定制导出.xlsx"; destPath=UniServerModule()->FilesFolder+"临时文件\\下载表格\\"+UniMainModule()->loginUserNo+UniMainModule()->loginUserName; //强制在服务端生成临时文件保存目录 if(!DirectoryExists(destPath)) { ForceDirectories(destPath.c_str()); } destFile=destPath+"\\"+tempFile; //保存表格到服务器端的临时目录 xls->Save(destFile); //选择本地保存目录和文件名 //if(!SaveDialog1->Execute() ) /*有问题,服务端显示*/ // return; //浏览器端将服务器端默认临时表格文件下载保存成本地新名字 //UniSession->SendFile(destFile,SaveDialog1->FileName); UniSession->SendFile(destFile); } Quote Link to comment Share on other sites More sharing options...
Oliver Morsch Posted August 23, 2018 Share Posted August 23, 2018 I wish my customers can select where to save file he want before download from server,I have put a saveDialog in the form,but when the the saveDialog is executed ,it display in the server ,not in the browser. Which browser? Quote Link to comment Share on other sites More sharing options...
55143681 Posted June 29, 2021 Author Share Posted June 29, 2021 On 8/23/2018 at 5:08 PM, Oliver Morsch said: Which browser? Google. Quote Link to comment Share on other sites More sharing options...
Oliver Morsch Posted June 29, 2021 Share Posted June 29, 2021 You can use Microsoft Edge browser for example. It has a setting, so that the user will be asked what to do with the file (i.e. "save as ..."). Quote Link to comment Share on other sites More sharing options...
55143681 Posted June 30, 2021 Author Share Posted June 30, 2021 20 hours ago, Oliver Morsch said: You can use Microsoft Edge browser for example. It has a setting, so that the user will be asked what to do with the file (i.e. "save as ..."). Just as what you say,thanks. Google,360...all support that. Quote Link to comment Share on other sites More sharing options...
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.