Page 1 of 1

Export form to CSV file

Posted: Wed Jun 18, 2025 1:39 pm
by nadir
Hello,

I want to add a new action button besides the print button. It should allow downloading the contents of the form as a CSV file. I read the following post for exporting form as CSV file:

viewtopic.php?t=10071

I used following code to display the action button:

Code: Select all

if(nuFormType() == 'browse'){
    nuAddActionButton('DownloadCSV', 
                      '', 
                      'nuSetProperty("browse_sql",nuCurrentProperties().browse_sql); nuRunPHP("DownloadCSV")',      
                      'Download to Excel',
                      'fa-fw fa fa-file-excel fa-lg'); 
}
How do I get the form data exported to CSV file and then start the download ?

Thanks,
Nadir

Re: Export form to CSV file

Posted: Wed Jun 18, 2025 2:02 pm
by kev1n
Hi,

Do you want to download just the current record as CSV or a Browse Form?

In any case, you will need to create a Procedure that selects the fields and downloads the data.

:arrow: See Code-Library

Re: Export form to CSV file

Posted: Wed Jun 18, 2025 5:14 pm
by nadir
Hi,

I want to download the browse form. Can you provide sample code for exporting the browse form to csv and starting the download

Re: Export form to CSV file

Posted: Wed Jun 18, 2025 5:29 pm
by kev1n
Sample code can be found in the Code Library, see link above

Re: Export form to CSV file

Posted: Thu Jun 19, 2025 8:04 am
by nadir
I followed the instructions in the Code Library document. The CSV download button works fine. Thanks.