From 51c7608a44671076096db3ce40b3710fb8affc37 Mon Sep 17 00:00:00 2001 From: Alexey Mazurin Date: Thu, 19 Mar 2015 10:21:25 +0400 Subject: Support of encrypted xlsx files Added support for reading encrypted xlsx files in accordance with [MS-OFFCRYPTO]: Office Document Cryptography Structure https://msdn.microsoft.com/en-us/library/cc313071(v=office.12).aspx Support of standard and agile encryption modified: lib/Spreadsheet/ParseXLSX.pm new file: t/data/encryption-agile-123q.xlsx new file: t/data/encryption-standard-default-password.xlsx new file: t/encryption.t --- t/data/encryption-agile-123q.xlsx | Bin 0 -> 13312 bytes t/data/encryption-standard-default-password.xlsx | Bin 0 -> 12288 bytes t/encryption.t | 30 +++++++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 t/data/encryption-agile-123q.xlsx create mode 100644 t/data/encryption-standard-default-password.xlsx create mode 100644 t/encryption.t (limited to 't') diff --git a/t/data/encryption-agile-123q.xlsx b/t/data/encryption-agile-123q.xlsx new file mode 100644 index 0000000..be3b561 Binary files /dev/null and b/t/data/encryption-agile-123q.xlsx differ diff --git a/t/data/encryption-standard-default-password.xlsx b/t/data/encryption-standard-default-password.xlsx new file mode 100644 index 0000000..a863c1b Binary files /dev/null and b/t/data/encryption-standard-default-password.xlsx differ diff --git a/t/encryption.t b/t/encryption.t new file mode 100644 index 0000000..6def0f4 --- /dev/null +++ b/t/encryption.t @@ -0,0 +1,30 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; + +use lib::Spreadsheet::ParseXLSX; + +my $parser = Spreadsheet::ParseXLSX->new(); +my $workbook = $parser->parse("t/data/encryption-agile-123q.xlsx", {password => '123q'}); + +my $worksheet; +my $cell; + +$worksheet = $workbook->worksheet(0); +ok(defined($workbook)); + +$cell = $worksheet->get_cell(1, 1); +ok(defined($cell) && $cell->value() eq 'abcdefgABCDEFG'); + + +open FH, "t/data/encryption-standard-default-password.xlsx"; +$workbook = $parser->parse(\*FH); + +ok(defined($workbook)); + +$worksheet = $workbook->worksheet(0); +$cell = $worksheet->get_cell(22, 8); +ok(defined($cell) && $cell->value() == 1911); + +done_testing; -- cgit v1.2.3-54-g00ecf