开发者

how to add worksheet in the excel workbook using php

how to i add the worksheet in the excel work book using php.

i am using this code to to write text in the excel sheet using php

            include("excelwriter.inc.php");

    $excel=new ExcelWriter("myXls.xls");

    if($excel==false)
        echo $excel->error;


    $excel->writeLine($myArr);
    $myArr=array("Recurring Payment / Deduct (Info Type P0014)");
    $excel->writeLine($myArr);
    $myArr=array(" ");
    $excel->writeLine($myArr);
            $excel->close();
    $filesh = "myXls.xls";

    header("Pragma: public");
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Content-Type: application/force-download");
    hea开发者_Go百科der("Content-Disposition: attachment; filename=".basename($filesh));
    header("Content-Description: File Transfer");
    readfile($filesh);

excelwriter.inc.php

      */
    function writeRow()
    {
        if($this->state!="OPENED")
        {
            $this->error="Error : Please open the file.";
            return false;
        }   
        if($this->newRow==false)
            fwrite($this->fp,"<tr>");
        else
            fwrite($this->fp,"</tr><tr>");
        $this->newRow=true; 
    }

    /*
    * @Params : $value : Coloumn Value
    * @Return : Void
    */
    function writeCol($value)
    {
        if($this->state!="OPENED")
        {
            $this->error="Error : Please open the file.";
            return false;
        }   
        fwrite($this->fp,"<td class=xl24 width=64 >$value</td>");
    }
}

But i did't know how to add the worksheet in the excel book please guide me.


It looks as though the ExcelWriter library that you're using is actually writing an HTML table rather than a real Excel file. To create a workbook with more than one worksheet, you'll need to use a library that generates real Excel files, such as PHPExcel rather than trying to con MS Excel into believing that HTML markup is a real spreadsheet

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜