PostNuke

Flexible Content Management System

News

Export to Excel Function

Contributed by nice trick ;) on Dec 21, 2001 - 11:42 AM

The only thing that needs work is the Content-type which depends on version of excel. Anyway here it is:


function exportsub($uname)


{


global $uname, $dbconn, $pntable, $admin;


Header("Content-type: Excel.sheet");


Header("Content-Disposition: filename=$uname.csv");





$column = &$pntable['whatever_column'];


$result = $dbconn->Execute("SELECT $column[whatever], $column[whatever2] FROM $pntable[whatever]");


while(list($whatever,$whatever2) = $result->fields) {


print"$whatever,$whatever2n";




$result->MoveNext();


}


exit;


}




Let me know if yall use it. I'm using it for the export of subcontractor and cost control information. Works good.


builder@biltright.com
3029