Skip Menu |

This queue is for tickets about the Spreadsheet-Write CPAN distribution.

Report information
The Basics
Id: 74682
Status: rejected
Priority: 0/
Queue: Spreadsheet-Write

People
Owner: Nobody in particular
Requestors: ftl [...] dnv.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Read image from memory
Thanks for a fine and very useful module, again! When generating images from e.g. GD that I want to insert into a spreadsheet, saving to file and then import do make some overhead. I added a new feature that 'filenames' sent as ref to scalar actually contains the data itself. In general, two changes, (line numbers are ref to version 2.37) Worksheet.pm, row 4906, allow $image to be a ref to SCALAR sub insert_image ..... croak "Couldn't locate $image: $!" unless -e $image || ref $image eq 'SCALAR'; Workbook.pm, row 1580, test if '$filename' is a ref to 'SCALAR' sub _process_images { .... my $data; if (ref $filename eq 'SCALAR') { $data = $$filename; } else { my $fh = FileHandle->new($filename); .... $fh->close; } Test.pl ----------------- use strict; use GD; use Spreadsheet::WriteExcel; my $im = GD::Image->new(15,15 ); my $im_bgcolor = $im->colorAllocate(map {hex($_) } unpack 'a2a2a2', 'CCCCCC'); my $im_color = $im->colorAllocate(map {hex($_) } unpack 'a2a2a2', '00CCFF'); $im->filledRectangle(3,3,12,12,$im_color); my $im_png = $im->png(); my $workbook = Spreadsheet::WriteExcel->new('simple.xls'); my $worksheet = $workbook->add_worksheet(); $worksheet->write(0, 0, 'Hi Excel!'); $worksheet->insert_image(1, 1, \$im_png); Documentation of insert_image ----------------------------- insert_image($row, $col, $filename, $x, $y, $scale_x, $scale_y) .... if $filename is ref to SCALAR, then the parmeter is considered to contain the image itself. If the same image is used multiple times, make sure to use the same reference, as same image used multiple times are stored only once. (sorry for using manual diff....)
I know I am getting to this 6 years late, but I think this patch is is for a Spreadsheet::WriteExcel, not for Spreadsheet::Write. It sounds great, just does not seem to be for the right module.