Reputation: 596
I wanted to generate xls file with multiple sheets. So, I took help from the below mentioned link.
http://pear.php.net/package/Spreadsheet_Excel_Writer
Using the tutorial documentation from the same i was able to create multiple sheets in my xls file. i.e, in my test.xls file i was able to create sheet1, sheet2, sheet2 and so on.
Now, i want add a link in the content of sheet1 so that sheet2 displays the data. I was going through the Worksheet::writeUrl method. But, i failed to put links in the content.
Sample code has been given below:
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();
Please help me to add link.
Upvotes: 0
Views: 709
Reputation: 212512
Your sheet name has a space, so it needs to be quoted in the hyperlink. I can't recall if that means
'internal:John Smith'!A1
or
internal:'John Smith'!A1
suspect the latter, but I haven't actually checked
Upvotes: 1