summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorzhouzhen1 <zhouzhen1@gmail.com>2015-10-03 15:42:07 +0800
committerzhouzhen1 <zhouzhen1@gmail.com>2015-10-03 15:42:07 +0800
commitaef74127ef74114e7fb30d16037b810ed93635d7 (patch)
treecb8975e4e6a196418141986aba8aa152d3566f5d /lib
parent2524f3b910282998be8fb967eb90d50a7f38ec3f (diff)
downloadspreadsheet-parsexlsx-aef74127ef74114e7fb30d16037b810ed93635d7.tar.gz
spreadsheet-parsexlsx-aef74127ef74114e7fb30d16037b810ed93635d7.zip
add support for having absolute path in internal xml file targets
Diffstat (limited to 'lib')
-rw-r--r--lib/Spreadsheet/ParseXLSX.pm21
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/Spreadsheet/ParseXLSX.pm b/lib/Spreadsheet/ParseXLSX.pm
index ad7f54c..f8daaae 100644
--- a/lib/Spreadsheet/ParseXLSX.pm
+++ b/lib/Spreadsheet/ParseXLSX.pm
@@ -714,6 +714,7 @@ sub _extract_files {
my $wb_name = ($rels->find_nodes(
qq<//Relationship[\@Type="$type_base/officeDocument"]>
))[0]->att('Target');
+ $wb_name =~ s/^\///;
my $wb_xml = $self->_parse_xml($zip, $wb_name);
my $path_base = $self->_base_path_for($wb_name);
@@ -722,25 +723,35 @@ sub _extract_files {
$self->_rels_for($wb_name)
);
+ my $get_path = sub {
+ my ($p) = @_;
+ if ($p !~ /^\//) {
+ return $path_base . $p;
+ } else {
+ $p =~ s/^\///;
+ return $p;
+ }
+ };
+
my ($strings_xml) = map {
- $zip->memberNamed($path_base . $_->att('Target'))->contents
+ $zip->memberNamed(&$get_path($_->att('Target')))->contents
} $wb_rels->find_nodes(qq<//Relationship[\@Type="$type_base/sharedStrings"]>);
my $styles_xml = $self->_parse_xml(
$zip,
- $path_base . ($wb_rels->find_nodes(
+ &$get_path(($wb_rels->find_nodes(
qq<//Relationship[\@Type="$type_base/styles"]>
- ))[0]->att('Target')
+ ))[0]->att('Target'))
);
my %worksheet_xml = map {
- if ( my $sheetfile = $zip->memberNamed($path_base . $_->att('Target'))->contents ) {
+ if ( my $sheetfile = $zip->memberNamed(&$get_path($_->att('Target')))->contents ) {
( $_->att('Id') => $sheetfile );
}
} $wb_rels->find_nodes(qq<//Relationship[\@Type="$type_base/worksheet"]>);
my %themes_xml = map {
- $_->att('Id') => $self->_parse_xml($zip, $path_base . $_->att('Target'))
+ $_->att('Id') => $self->_parse_xml($zip, &$get_path($_->att('Target')))
} $wb_rels->find_nodes(qq<//Relationship[\@Type="$type_base/theme"]>);
return {