Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SaveDialog in Intraweb 14
#1
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;
Reply
#2
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.
Reply
#3
Thanks Alexandre.
Can you give me an example where the client selects the destination directory ??
Reply
#4
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.
Reply
#5
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 ?
Reply
#6
https://github.com/Atozed/IntraWeb/tree/...i/Features
Reply
#7
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?
Reply
#8
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
Reply
#9
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.
Reply
#10
Wink 
In the properties of the Button.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)