summaryrefslogtreecommitdiffstats
path: root/lib/Spreadsheet/Template/Writer/Excel.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Spreadsheet/Template/Writer/Excel.pm')
-rw-r--r--lib/Spreadsheet/Template/Writer/Excel.pm50
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/Spreadsheet/Template/Writer/Excel.pm b/lib/Spreadsheet/Template/Writer/Excel.pm
new file mode 100644
index 0000000..c2c6028
--- /dev/null
+++ b/lib/Spreadsheet/Template/Writer/Excel.pm
@@ -0,0 +1,50 @@
+package Spreadsheet::Template::Writer::Excel;
+use Moose::Role;
+
+use Class::Load;
+
+with 'Spreadsheet::Template::Writer';
+
+requires 'excel_class';
+
+has excel => (
+ is => 'ro',
+ isa => 'Object',
+ lazy => 1,
+ default => sub {
+ my $self = shift;
+ load_class($self->excel_class);
+ $self->excel_class->new($self->_fh);
+ },
+);
+
+has _fh => (
+ is => 'ro',
+ isa => 'FileHandle',
+ lazy => 1,
+ default => sub {
+ open my $fh, '>', $self->_output
+ or die "Failed to open filehandle: $!";
+ binmode $fh;
+ return $fh;
+ },
+);
+
+has _output => (
+ is => 'ro',
+ isa => 'ScalarRef[Str]',
+ lazy => 1,
+ default => sub { \(my $str) },
+);
+
+sub write {
+ my $self = shift;
+
+ # ...
+
+ return ${ $self->_output };
+}
+
+no Moose::Role;
+
+1;