[FX.php List] creating an export file

DC dan.cynosure at dbmscan.com
Thu Apr 28 12:09:20 MDT 2005


go to PHPCLASSES.org and get the excel stream wrapper. it gives you bare 
bones excel file output. pretty cool and small code too.

http://www.phpclasses.org/browse/package/1919.html

Here's how I use this class in my FMP system (I just exit and return the 
excel generating file by including it):

NOTE: the excel class deals with a simple associative array. you have to 
get an associative array in a recordset format out of FX.php result 
data. i'll leave that as an excercise for the reader.

// pseudocode - will not work out of the box.
$column_array = transpose_array($FX_result['data']);

if ($_GET['format']=="excel") {
// only pass a few fields over to the excel doc
// this include file expects to see a "recordset" array called $assoc
// use FMP field names as keys and create new array with the fields you 
// want from the FX.php array
$culled_column_array=array(
'Index Number'=>$column_array['Index Number'],
'Category'=>$column_array['Cat'],
'Company'=>$column_array['Company Name'],
'Timing'=>$column_array['Timing']);
// transpose the array back
$assoc=transpose_array($culled_column_array);
include("excel_export_test.php");
// this include slightly modified from the phpclasses page
// so it will understand that $assoc is the array i want it to deal with
// this forces the code to exit here without sending a new page to the 
browser
// this is ok since the excel_export code sends its own headers and 
everything
exit();
}

HTH. if you get something good going or improve on this technique, 
please let us all know!

dan

Eric Pingel had written:
> I am trying to create and export file using fx.php.  I have a FileMaker 6
> Unlimited database connected to users via fx.php.  I am looking to have
> the users select various database fields and create an export that they
> can then use in Excel.  I have used a script for php/mysql and it works
> there, but porting it over to fx.php/fmpro has given me trouble.  Does
> anyone have any ideas as to how to create an .xls file from fx.php?
> 


More information about the FX.php_List mailing list