我正在使用pear.php.net提供的“Writer.php”文件来生成excel文件。我发现很难做的是将工作表添加到现有的工作簿中。我尝试了几件事,但没能添加工作表。我真的不擅长OOP,任何帮助都将不胜感激。提前谢谢。
以下是生成excel文件的php代码:
<?php
session_start();
require_once('Spreadsheet/Excel/Writer.php');
include ("config.php");
$username = $_SESSION['username'];
$uid = $_SESSION['uid'];
$name_in_logo=$_POST['name_in_logo'];
if (!is_dir($username))
{
$oldumask = umask(0);
mkdir($username, 0777);
umask($oldumask);
}
$now = new DateTime(null, new DateTimeZone('Asia/Kolkata'));
$date_time = $now->format('d-m-Y H:i:s');
$filename1 = $username;
$filename2 = "_Design Brief ";
$filename3 = ".xls";
$final_filename = $filename1.$filename2.$date_time.$filename3;
$path_xls = "/";
$path_to_xls = $username.$path_xls.$final_filename;
$workbook = new Spreadsheet_Excel_Writer($path_to_xls);
$_SESSION['objworkbook'] = $workbook;
$worksheet =& $workbook->addWorksheet('Design Brief Details');
$worksheet->write(0, 0, 'uid');
$worksheet->write(0, 1, $uid);
$worksheet->write(1, 0, 'name_in_logo');
$worksheet->write(1, 1, $name_in_logo);
$workbook->close();
?>