Atozed Forums
SaveDialog in Intraweb 14 - Printable Version

+- Atozed Forums (https://www.atozed.com/forums)
+-- Forum: Atozed Software (https://www.atozed.com/forums/forum-1.html)
+--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html)
+---- Forum: English (https://www.atozed.com/forums/forum-16.html)
+----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html)
+----- Thread: SaveDialog in Intraweb 14 (/thread-3296.html)



SaveDialog in Intraweb 14 - matjequier - 06-07-2023

Hi, I am making a program for internet using for this intraweb 14.0.29 and I would like your help to solve the creation of a file.

In the win32 version of the program create an excel and download it wherever the user wants, but with Intraweb it does not make it work, using the typical TFileSaveDialog components to select the path.

I use something like this.
Code:
fdquery1.Open();

if fdquery1.IsEmpty = FALSE then
try
Report := TFlexCelReport.Create(true);

if not SaveDialog1.Execute then exit;

Report.AddTable('fdquery1',fdquery1, TRecordCountMode.SlowCount, TDisposeMode.DoNotDispose);

  Report.SetValue('empresa',combobox7.text); // .SetCellValue(1, 1, statusbar1.panels[2].Text);
  Report.SetValue('ejercicio',edit9.Text); // .SetCellValue(1, 1, statusbar1.panels[2].Text);
  Report.SetValue('periodo',combobox8.Text); // .SetCellValue(1, 1, statusbar1.panels[2].Text);
  Report.SetValue('fecha',datetimetostr(now)); // .SetCellValue(1, 1, statusbar1.panels[2].Text);

  Report.Run(ExtractFilePath(application.ExeName)+'\EERR_SAP.xlsx', SaveDialog1.FileName);

  if MessageDlg('Se ha exportado correctamente. ¿Desea abrir el archivo generado?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then
  begin
    ShellExecute(0, 'open', PCHAR(SaveDialog1.FileName), nil, nil, SW_SHOWNORMAL);
  end;
  finally

FDCONNECTion1.close;
  end;



RE: SaveDialog in Intraweb 14 - Alexandre Machado - 06-09-2023

This won't work. When you run SaveDialog, this is a code that runs on the server computer, not on the user computer.... It won't open a FileSave dialog on their side.

You need to execute a file download. Create a file on the server side and call SendFile() method of the WebApplication. It will prompt the user to save the file on their side.


RE: SaveDialog in Intraweb 14 - matjequier - 06-09-2023

Thanks Alexandre.
Can you give me an example where the client selects the destination directory ??


RE: SaveDialog in Intraweb 14 - Alexandre Machado - 06-09-2023

Hi,

you cannot directly force a user to select a specific directory for downloading a file due to security restrictions imposed by web browsers. The file download process is controlled by the user's browser settings.

When a file is downloaded, the browser prompts the user to choose the download location or uses the default location specified in the browser settings. When/if prompted, the browser typically provides a standard save dialog, and the user has the freedom to select any directory they prefer or stick with the default.


RE: SaveDialog in Intraweb 14 - matjequier - 06-10-2023

Thank you very much and I understand what you say.
First I need to create the file locally on the server and then send it ?
Please can you send me a small code example of how I have to do it ?


RE: SaveDialog in Intraweb 14 - PaulWeem - 06-11-2023

https://github.com/Atozed/IntraWeb/tree/master/XIV/Delphi/Features


RE: SaveDialog in Intraweb 14 - matjequier - 06-12-2023

Thanks Paul.
Finally I was able to download the file Ineed, but after downloading it the page is stuck with the symbol of thinking.
What could it be? How do I solve it?


RE: SaveDialog in Intraweb 14 - PaulWeem - 06-13-2023

Did you do this in your own app or in the features demo?

If in your own app, did you put the following code in the the scriptevents.onclick event:

ReleaseLock();
GActivateLock=false;
return true;


Cheers, Paul


RE: SaveDialog in Intraweb 14 - matjequier - 06-13-2023

I test my own app.
Where is the scriptevents.onclick ??
It's from the main form, servercontroller or the button ??
Sorry, its my first intraweb app.


RE: SaveDialog in Intraweb 14 - PaulWeem - 06-13-2023

In the properties of the Button.