Reputation: 967
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");
header("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.
Upvotes: 0
Views: 2267
Reputation: 212412
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
Upvotes: 1