http://www.perlmonks.org?node_id=714805


in reply to Internal links in Excel

Change:

foreach my $link ( @links ) { my $url = "q{internal:'$link'!A1}"; $worksheet1->write_url ( $row,$col, $url,$label ); $row++; $col++; }

Into:

foreach my $link ( @links ) { my $url = "internal:'$link'!A1"; $worksheet1->write_url ( $row,$col, $url,$label ); $row++; $col++; }

I'm guessing your confusing comes from looking at the examples in Spreadsheet::WriteExcel and not knowing q() and qq().

The examples from Spreadsheet::WriteExcel:

$worksheet->write_url('A6', 'internal:Sheet2!A1' + ); $worksheet->write_url('A7', 'internal:Sheet2!A1', $format + ); $worksheet->write_url('A8', 'internal:Sheet2!A1:B2' + ); $worksheet->write_url('A9', q{internal:'Sales Data'!A1} + );

I'm guessing the $worksheet->write_url('A9',  q{internal:'Sales Data'!A1}); confused you but it means exactly the same as : $worksheet->write_url('A9',  'internal:\'Sales Data\'!A1');

In essence: q(foo) is the same 'foo' which is the same as q{foo} (that is: single quotes but you get to choose the delimiter).
qq(foo) is the same 'foo' which is the same as qq{foo} (that is: double quotes but you get to choose the delimiter).

I tested this by creating an xls file via Spreadsheet::WriteExcel and opening it in OpenOffice. Don't have access to Microsoft Excel at the moment of this writing.

Replies are listed 'Best First'.
Re^2: Internal links in Excel
by anand_perl (Novice) on Oct 03, 2008 at 04:06 UTC

    Thanks Animator!!!

    Your solution works!!
      'BATSOPLINK'!A1 this is the output I get when I try to print it via my $url = "internal:'$val$i'!A1"; Want to get rid of "!A1" and just want to print the value which refers to the cell