«

»

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(
        'Server',
        'Database',
        'Procedure',
        'Type',
        'Created',
        'Altered',
        'Last Run',
        'NOTES',
    ),
);
$report = new csvReports($params);

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>