[英]how to add worksheet in the excel workbook using php
如何使用php在Excel工作簿中添加工作表。
我正在使用此代碼使用php在Excel工作表中編寫文本
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>");
}
}
但是我不知道如何在Excel書中添加工作表,請指導我。
看來您使用的ExcelWriter庫實際上是在編寫HTML表,而不是實際的Excel文件。 要創建一個包含多個工作表的工作簿,您需要使用一個生成真實 Excel文件的庫,例如PHPExcel,而不是試圖讓MS Excel認為HTML標記是真實的電子表格。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.