我想生成包含多个工作表的xls文件。所以,我从下面提到的链接中获得了帮助。
http://pear.php.net/package/Spreadsheet_Excel_Writer
使用相同的教程文档我能够在我的xls文件中创建多个工作表。即,在我的test.xls文件中,我能够创建sheet1,sheet2,sheet2等等。
现在,我想在sheet1的内容中添加一个链接,以便sheet2显示数据。我正在浏览Worksheet :: writeUrl方法。但是,我没有在内容中添加链接。
示例代码如下:
require_once 'Spreadsheet/Excel/Writer.php';
$workbook = new Spreadsheet_Excel_Writer();
$workbook->send('test.xls');
$worksheet =& $workbook->addWorksheet('Report');
$worksheet1 =& $workbook->addWorksheet('John Smith');
$sheet = "John Smith";
$worksheet->write(0, 0, 'Name');
$worksheet->write(0, 1, 'Age');
$format =& $worksheet->writeUrl(1,0 ,"internal:".$sheet."!A1", $sheet);
$worksheet->write(1, 1, 30);
$worksheet->write(2, 0, 'Johann Schmidt');
$worksheet->write(2, 1, 31);
$worksheet->write(3, 0, 'Juan Herrera');
$worksheet->write(3, 1, 32);
$worksheet1->write(0, 0, 'Name');
$worksheet1->write(0, 1, 'Age');
$worksheet1->write(1, 0, 'aaaaaa');
$worksheet1->write(1, 1, 30);
$worksheet1->write(2, 0, 'bbbbb');
$worksheet1->write(2, 1, 31);
$worksheet1->write(3, 0, 'ccccc');
$worksheet1->write(3, 1, 32);
$workbook->close();
请帮我添加链接。
答案 0 :(得分:1)
您的工作表名称有空格,因此需要在超链接中引用它。 我不记得那是否意味着
'internal:John Smith'!A1
或
internal:'John Smith'!A1
怀疑后者,但我实际上没有检查过