summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-01-29 15:01:05 -0500
committerJesse Luehrs <doy@tozt.net>2014-01-29 15:01:05 -0500
commit58e422a18e68ed948a791ffba824fd67689d02df (patch)
treeeef8e15ec093499a161ccfb75a80d03735998f4e
parent305d1a772ccfff825806fe2dbcbc822a85f05145 (diff)
downloadspreadsheet-parsexlsx-58e422a18e68ed948a791ffba824fd67689d02df.tar.gz
spreadsheet-parsexlsx-58e422a18e68ed948a791ffba824fd67689d02df.zip
support locked and hidden cells (#15)
-rw-r--r--lib/Spreadsheet/ParseXLSX.pm12
-rw-r--r--t/bug-15.t25
-rw-r--r--t/data/bug-15.xlsxbin0 -> 13602 bytes
3 files changed, 34 insertions, 3 deletions
diff --git a/lib/Spreadsheet/ParseXLSX.pm b/lib/Spreadsheet/ParseXLSX.pm
index 9043284..72d8a58 100644
--- a/lib/Spreadsheet/ParseXLSX.pm
+++ b/lib/Spreadsheet/ParseXLSX.pm
@@ -499,20 +499,26 @@ sub _parse_styles {
} $styles->find_nodes('//fonts/font');
my @format = map {
- my $alignment = $_->first_child('alignment');
+ my $alignment = $_->first_child('alignment');
+ my $protection = $_->first_child('protection');
Spreadsheet::ParseExcel::Format->new(
IgnoreFont => !$_->att('applyFont'),
IgnoreFill => !$_->att('applyFill'),
IgnoreBorder => !$_->att('applyBorder'),
IgnoreAlignment => !$_->att('applyAlignment'),
IgnoreNumberFormat => !$_->att('applyNumberFormat'),
+ IgnoreProtection => !$_->att('applyProtection'),
FontNo => 0+$_->att('fontId'),
Font => $font[$_->att('fontId')],
FmtIdx => 0+$_->att('numFmtId'),
- # Lock => $iLock,
- # Hidden => $iHidden,
+ Lock => $protection
+ ? $protection->att('locked')
+ : 0,
+ Hidden => $protection
+ ? $protection->att('hidden')
+ : 0,
# Style => $iStyle,
# Key123 => $i123,
AlignH => $alignment
diff --git a/t/bug-15.t b/t/bug-15.t
new file mode 100644
index 0000000..5ec62b2
--- /dev/null
+++ b/t/bug-15.t
@@ -0,0 +1,25 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+
+use Spreadsheet::ParseXLSX;
+
+my $wb = Spreadsheet::ParseXLSX->new->parse('t/data/bug-15.xlsx');
+my $ws = $wb->worksheet(1);
+
+my $b2 = $ws->get_cell(1, 1);
+ok(exists $b2->get_format->{Hidden});
+ok(exists $b2->get_format->{Lock});
+ok(!$b2->get_format->{IgnoreProtection});
+ok(!$b2->get_format->{Hidden});
+ok(!$b2->get_format->{Lock});
+
+my $b4 = $ws->get_cell(3, 1);
+ok(exists $b4->get_format->{Hidden});
+ok(exists $b4->get_format->{Lock});
+ok(!$b4->get_format->{IgnoreProtection});
+ok($b4->get_format->{Hidden});
+ok(!$b4->get_format->{Lock});
+
+done_testing;
diff --git a/t/data/bug-15.xlsx b/t/data/bug-15.xlsx
new file mode 100644
index 0000000..d31d1dd
--- /dev/null
+++ b/t/data/bug-15.xlsx
Binary files differ