Help!!! Exporting data to excel

Discussion in 'PHP' started by mylooieva, Mar 14, 2010.

  1. #1
    Hi,

    I am trying to export mysql data to excel. The query i use to call is :

    $result=mysql_query("select no1, no2, tool1, tool2, tool3, tool4, tool5, tool6, tool7, tool8, DATE_FORMAT(dReceived, '%d %b %Y') AS dReceived, DATE_FORMAT(dShipment, '%d %b %Y') AS dShipment from table1 where dReceived LIKE '$year-$m-%' UNION select no1, no2, tool1, tool2, tool3, tool4, tool5, tool6, tool7, tool8, DATE_FORMAT(dReceived, '%d %b %Y') AS dReceived, DATE_FORMAT(dShipment, '%d %b %Y') AS dShipment from table2 where dReceived LIKE '$year-$m-%' order by no1 asc");

    and the function is:

    // Functions for export to excel.
    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;
    }

    It is success but the output of no1 it just display the number but i want in 5 digit.

    what i mean is column no1 it disply in excel now is 311 but i want it to display in 00311.

    can anyone help me??

    Thanks.
     
    mylooieva, Mar 14, 2010 IP