Custom File Export to Excel

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
andyrav
User
Posts: 635

Custom File Export to Excel

Post by andyrav »

Hi
Can anyone help me to create a button in a Custom file to export a query into Excel?
so i have ..
$sql = "Query";
echo $db->ExecuteHtml($sql, array( "fieldcaption" => TRUE, "tablename" => array("status")));
Displays the result
then i would like a button to click on to export it into excel.

many thanks in advanced


arbei
User
Posts: 9284

Post by arbei »

You need to refer to the function "ExportData" in the generated files and write your own script to handle the export.

If you need export feature, you better create a view for the table instead of using Custom File.


andyrav
User
Posts: 635

Post by andyrav »

Thanks, can you help i have no idea how to do this?
Just need a button to click on the download the export.

cheers


arbei
User
Posts: 9284

Post by arbei »

  1. Create a button with the link that has a parameter to tell the custom page you need to export.
    e.g. <Custom Page>.php?export=excel

  2. In the custom page, you need to check the parameter and handle the export.
    e.g.

if (@$_GET["export"] == "excel") {
//code to perform the export.
}

You can refer to the function "ExportData" in the generated files and write your own script to handle the export.

As said:
If you need export feature, you better create a view for the table instead of using Custom File.


andyrav
User
Posts: 635

Post by andyrav »

Hi
Can anyone help with a example on who to use the ExportData function from within a custom page?
many thanks


mobhar
User
Posts: 11660

Post by mobhar »

arbei wrote:
You can refer to the function "ExportData" in the generated files and write your
own script to handle the export.

See and learn the code from "ExportData" function in the generated *list and/or *view.php files.


Post Reply