Re: [PHP] MySQL/PHP to Excel
Preformatted? You mean how values are positioned, how wide columns are, how many number behind the dot? Can't you set that with your library?
Re: [PHP] MySQL/PHP to Excel
Quote:
Originally Posted by
Daevius
Preformatted? You mean how values are positioned, how wide columns are, how many number behind the dot? Can't you set that with your library?
Yeah thats right, but i've got the faintess idea on going arround it :x
Re: [PHP] MySQL/PHP to Excel
Just a bump - Can someone point me in the right direction?
many thanks
Re: [PHP] MySQL/PHP to Excel
Your "library" does not, in fact, do little more than produce a CSV file (well, tab seperated but same difference). This isn't an excel file and it can't, by definition, contain the excel formatting you require.
Your "solution" would be to scrap this and get a real Excel export library - mind that they do tend to cost money though.
Re: [PHP] MySQL/PHP to Excel
you could use openoffice libs as free solution
Re: [PHP] MySQL/PHP to Excel
I've done a lot of digging and worked it out, not worked out the formatting as of yet but i will look into at work tommorow - currently i can postion the data from mysql into any cell i choose which was something i wanted to achieve
Here is the code im using atm
PHP Code:
<?
mysql_connect("loclahost","user","pass");
mysql_select_db("databaseirl");
$result=mysql_query("SELECT * FROM title WHERE account = 'suspended' ORDER BY username ASC");
function xlsBOF() {
echo pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0);
return;
}
function xlsEOF() {
echo pack("ss", 0x0A, 0x00);
return;
}
function xlsWriteNumber($Row, $Col, $Value) {
echo pack("sssss", 0x203, 14, $Row, $Col, 0x0);
echo pack("d", $Value);
return;
}
function xlsWriteLabel($Row, $Col, $Value ) {
$L = strlen($Value);
echo pack("ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L);
echo $Value;
return;
}
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");;
header("Content-Disposition: attachment;filename=spreadsheetnameirl.xls ");
header("Content-Transfer-Encoding: binary ");
xlsBOF();
xlsWriteLabel(0,0,"A bit of text didnt do no harm :)");
xlsWriteLabel(2,0,"ID");
xlsWriteLabel(2,1,"Title");
xlsWriteLabel(2,3,"Link");
$xlsRow = 3;
while($row=mysql_fetch_array($result)){
xlsWriteNumber($xlsRow,0,$row['sqlvalue1']);
xlsWriteLabel($xlsRow,1,$row['sqlvalue2']);
xlsWriteLabel($xlsRow,3,$row['sqlvalue3']);
$xlsRow++;
}
xlsEOF();
exit();
?>
Just looking into
atm - will keep this post updated