doy / spreadsheet-parsexlsx

parse XLSX files
http://metacpan.org/release/Spreadsheet-ParseXLSX
27 stars 35 forks source link

get_hyperlink does not work on files creatd by WriteXLSX #82

Open chcmt opened 6 years ago

chcmt commented 6 years ago

Here is the code to reproduce the problem :

`use strict; use warnings;

use Spreadsheet::ParseXLSX; use Excel::Writer::XLSX;

create XLSX file with an hyperlink :

sub create_file { my $file_name = shift or die; my $workbook = Excel::Writer::XLSX->new( $file_name ); my $worksheet = $workbook->add_worksheet( "URL" ); $worksheet->write_url( 0, 0, "http://search.cpan.org", "CPAN" ); $workbook->close(); }

Trying to read back the URL :

sub read_file { my $file_name = shift or die; my $parser = Spreadsheet::ParseXLSX->new(); my $workbook = $parser->parse( $file_name ) // die; my $worksheet = $workbook->worksheet( "URL" ); my $cell = $worksheet->{Cells}[0][0];

my $hyperlink = $cell->get_hyperlink(); if ( defined $hyperlink ) { print "hyperlink = ", join( ":", @$hyperlink ), "\n"; } else { my $value = $cell->value(); print "NO hyperlink (value=\"$value\")\n"; }

}

my $file_name = "url_bug.xlsx"; create_file( $file_name ); read_file( $file_name );

` When I run it, I get the "NO hyperlink" message. The Excel file is OK and does have an hyperlink I can click on in Excel.

gquipster commented 6 years ago

This should be solved by the code in my pull request #63

On 29 Nov 2017 11:05, "chcmt" notifications@github.com wrote:

Here is the code to reproduce the problem :

`use strict; use warnings;

use Spreadsheet::ParseXLSX; use Excel::Writer::XLSX; create XLSX file with an hyperlink :

sub create_file { my $file_name = shift or die; my $workbook = Excel::Writer::XLSX->new( $file_name ); my $worksheet = $workbook->add_worksheet( "URL" ); $worksheet->write_url( 0, 0, "http://search.cpan.org", "CPAN" ); $workbook->close(); } Trying to read back the URL :

sub read_file { my $file_name = shift or die; my $parser = Spreadsheet::ParseXLSX->new(); my $workbook = $parser->parse( $file_name ) // die; my $worksheet = $workbook->worksheet( "URL" ); my $cell = $worksheet->{Cells}[0][0];

my $hyperlink = $cell->get_hyperlink(); if ( defined $hyperlink ) { print "hyperlink = ", join( ":", @$hyperlink ), "\n"; } else { my $value = $cell->value(); print "NO hyperlink (value="$value")\n"; }

}

my $file_name = "url_bug.xlsx"; create_file( $file_name ); read_file( $file_name );

` When I run it, I get the "NO hyperlink" message. The Excel file is OK and does have an hyperlink I can click on in Excel.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/doy/spreadsheet-parsexlsx/issues/82, or mute the thread https://github.com/notifications/unsubscribe-auth/AIGOq25rnaQTU_moUFJQcrJ6cpib9QXOks5s7TpsgaJpZM4QuyHj .