0

我想用多张纸生成 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();

请帮我添加链接。

4

1 回答 1

1

您的工作表名称有一个空格,因此需要在超链接中引用。我不记得这是否意味着

'internal:John Smith'!A1

或者

internal:'John Smith'!A1

怀疑后者,但我还没有真正检查过

于 2012-06-29T06:40:36.630 回答