summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Changes1
-rw-r--r--lib/Spreadsheet/ParseXLSX.pm3
-rw-r--r--lib/Spreadsheet/ParseXLSX/Decryptor.pm2
3 files changed, 5 insertions, 1 deletions
diff --git a/Changes b/Changes
index ae2e726..4fff5d7 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,7 @@
Revision history for Spreadsheet-ParseXLSX
{{$NEXT}}
+ - Give a better error message when opening xls files (mchendriks, #52)
0.20 2015-12-05
- Fix the test suite on perls compiled with -Duselongdouble (Slaven
diff --git a/lib/Spreadsheet/ParseXLSX.pm b/lib/Spreadsheet/ParseXLSX.pm
index a9b501f..cf9319a 100644
--- a/lib/Spreadsheet/ParseXLSX.pm
+++ b/lib/Spreadsheet/ParseXLSX.pm
@@ -71,10 +71,11 @@ sub parse {
my $workbook = Spreadsheet::ParseExcel::Workbook->new;
if ($self->_check_signature($file)) {
- $file = Spreadsheet::ParseXLSX::Decryptor->open(
+ my $decrypted_file = Spreadsheet::ParseXLSX::Decryptor->open(
$file,
$self->{Password}
);
+ $file = $decrypted_file if $decrypted_file;
}
if (openhandle($file)) {
diff --git a/lib/Spreadsheet/ParseXLSX/Decryptor.pm b/lib/Spreadsheet/ParseXLSX/Decryptor.pm
index 660a544..7870685 100644
--- a/lib/Spreadsheet/ParseXLSX/Decryptor.pm
+++ b/lib/Spreadsheet/ParseXLSX/Decryptor.pm
@@ -25,6 +25,8 @@ sub open {
['EncryptionInfo', 'EncryptedPackage']
);
+ return unless $infoFH;
+
my $buffer;
$infoFH->read($buffer, 8);
my ($majorVers, $minorVers) = unpack('SS', $buffer);