Apr 20

csvReports.class Released

csvReports is a PHP class i built when i was doing report/query analysis at SFG. the purpose of the class is to generate Comma Separated Value files (.csv) which Microsoft Excel would them load up as a spreadsheet.

the main thing is that because the header is set in the class and each row is added using an associative array which matches keys to the header if i was to skip values the generation of the file will account for this on it’s own. it also wraps each cell in quotation for instances where you pass a , into a row which would break things

Download .zip

like with my autoBase.class i use a paramater array for the constructor

'saveFile'         => '_reports/rptMyNewReport.csv',        // save file for the .csv file, reletive to the PHP file that's instantiated the class
'newLog'         => true,                                // whether your creating a new log file
'noMemLimit'     => false,                                // disable the PHP Memory Limit
'header'         => array(),                                // header for the csv file

an example of your object initalization would be

$params = array(
    'saveFile'         => '_reports/testReport.csv',
    'noMemLimit'     => true,
    'header'        => array(
        'Last Run',
$report = new csvReports($params);

Leave a Reply

Your email address will not be published.