This file is indexed.

/usr/share/perl5/Spreadsheet/Wright.pm is in libspreadsheet-wright-perl 0.105-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
package Spreadsheet::Wright;

use 5.010;
use strict;
use warnings;
no warnings qw( uninitialized numeric );

BEGIN {
	$Spreadsheet::Wright::VERSION   = '0.105';
	$Spreadsheet::Wright::AUTHORITY = 'cpan:TOBYINK';
}

use Carp;
use IO::File;

sub new
{
	my ($class, %args) = @_;
	
	my $format   = $args{'format'} // 'auto';
	my $filename = $args{'file'}   // $args{'filename'};
	
	if (lc $format eq 'auto')
	{
		$format = ($filename =~ /\.([^\.]+)$/) ? lc($1) : 'auto';
	}
	
	my $implementation = {
		auto    => 'CSV',
		csv     => 'CSV',
		excel   => 'Excel',
		html    => 'HTML',
		json    => 'JSON',
		ods     => 'OpenDocument',
		odsxml  => 'OpenDocumentXML',
		text    => 'CSV',
		txt     => 'CSV',
		xhtml   => 'XHTML',
		xls     => 'Excel',
		xml     => 'OpenDocumentXML',
		}->{lc $format};
	
	my $self = eval
	{
		croak "Format $format is not supported" unless $implementation;
		$implementation = join '::', (__PACKAGE__, $implementation);
		eval "use $implementation;";
		die $@ if $@;
		return $implementation->new(%args);
	};
	
	if ($self and !$@)
	{
		return $self;
	}
	elsif ($args{'failsafe'})
	{
		$implementation = join '::', (__PACKAGE__, 'CSV');
		eval "use $implementation;";
		die $@ if $@;
		return $implementation->new(%args);
	}
	elsif ($@)
	{
		die $@;
	}
	else
	{
		croak "Could not instantiate spreadsheet!\n";
	}
}

sub DESTROY
{
	my $self = shift;
	$self->close;
}

sub error
{
	my $self = shift;
	return $self->{'_ERROR'};
}

sub _open
{
	my $self=shift;
	
	$self->{'_CLOSED'} && croak "Can't reuse a closed spreadsheet";
	
	my $fh = $self->{'_FH'};
	
	if(!$fh)
	{
		my $filename = $self->{'_FILENAME'} or return;
		$fh = IO::File->new;
		$fh->open($filename,"w")
			or croak "Can't open file $filename for writing: $!";
		$self->{'_FH'}=$fh;
	}
	
	return $self->_prepare;
}

sub _prepare
{
	return $_[0];
}

sub addrow
{
	my $self = shift;
	$self->_open() or return;
	
	my @cells;
	
	foreach my $item (@_)
	{
		if (ref $item eq 'HASH')
		{
			if (ref $item->{content} eq 'ARRAY')
			{
				foreach my $i (@{ $item->{'content'} })
				{
					my %newitem = %$item;
					$newitem{'content'} = $i;
					push @cells, \%newitem;
				}
			}
			else
			{
				push @cells, $item;
			}
		}
		else
		{
			push @cells, { content => $item };
		}
	}
	
	return $self->_add_prepared_row(@cells);
}

sub _add_prepared_row
{
	return $_[0];
}

sub addrows
{
	my $self = shift;
	foreach my $row (@_)
	{
		if (ref $row eq 'ARRAY')
		{
			$self->addrow(@$row);
		}
		elsif (!ref $row)
		{
			$self->addsheet($row);
		}
		else
		{
			carp "Could not add row.";
		}
	}
	return $self;
}

sub addsheet
{
	croak "addsheet not implemented!!\n";
}

sub freeze
{
	return $_[0];
}

sub close
{
	# noop
}

1;

__END__

=head1 NAME

Spreadsheet::Wright - simple spreadsheet worker

=head1 SYNOPSIS

  # EXCEL spreadsheet
  
  use Spreadsheet::Wright;
  
  my $s = Spreadsheet::Wright->new(
    file    => 'spreadsheet.xls',
    format  => 'xls',
    sheet   => 'Products',
    styles  => {
      money   => '($#,##0_);($#,##0)',
      },
    );
  
  $s->addrow('foo',{
      content         => 'bar',
      type            => 'number',
      style           => 'money',
      font_weight     => 'bold',
      font_color      => 42,
      font_face       => 'Times New Roman',
      font_size       => 20,
      align           => 'center',
      valign          => 'vcenter',
      font_decoration => 'strikeout',
      font_style      => 'italic',
      });
  $s->addrow('foo2','bar2');
  $s->freeze(1, 0);

  # CSV file
  
  use Spreadsheet::Wright;
  
  my $s = Spreadsheet::Wright->new(
    file        => 'file.csv',
    encoding    => 'iso8859',
    );
  die $s->error if $s->error;
  $s->addrow('foo', 'bar');

=head1 DESCRIPTION

C<Spreadsheet::Wright> is a fork of L<Spreadsheet::Write> and
may be used as a drop-in replacement.

C<Spreadsheet::Wright> writes files in CSV, Microsoft Excel,
HTML and OpenDocument formats. It is especially suitable
for building various dumps and reports where rows are built
in sequence, one after another.

It is not especially suitable for modifying existing files.

The name is a not just pun on "write" - the word "wright" means
worker or crafter, and C<Spreadsheet::Wright> does a lot of the
work of spreadsheet output for you!

=head2 Constructor

=over 4

=item C<< Spreadsheet::Wright->new(%args) >>

  $spreadsheet = Spreadsheet::Wright->new(
    file       => 'table.xls',
    styles     => {
      mynumber   => '#,##0.00',
      },
    );

Creates a new spreadsheet object. It takes a list of options. The
following are valid:

=over 4

=item * B<file> - filename of the new spreadsheet (mandatory)

=item * B<encoding> - encoding of output file (optional, csv format only)

=item * B<format> - format of spreadsheet - 'csv', 'xls', 'html', 'xhtml', 'xml', 'ods', 'json' or 'auto' (default).

=item * B<sheet> - first sheet name (optional, not supported by some formats)

=item * B<styles> - defines cell formatting shortcuts (optional)

=item * B<failsafe> - boolean - if true, falls back to CSV in emergencies

=back

If file format is 'auto' (or omitted), the format is guessed from the
filename extension, defaulting to 'csv'.

=back

=head2 Methods

=over 4

=item C<< addrow($cell_1, $cell_2, ...) >>

Adds a row into the spreadsheet. Takes arbitrary number of
arguments. Arguments represent cell values and may be strings or hash
references. If an argument is a hash reference, it takes the following
structure:

    content         value to put into cell
    style           formatting style, as defined in new()
    type            type of the content (defaults to 'auto')
    format          number format (see Spreadsheet::WriteExcel for details)
    font_weight     weight of font. Only valid value is 'bold'
    font_style      style of font. Only valid value is 'italic'
    font_decoration 'underline' or 'strikeout' (or both, space separated)
    font_face       font of column; default is 'Arial'
    font_color      color of font (see Spreadsheet::WriteExcel for color values)
    font_size       size of font
    align           alignment
    valign          vertical alignment
    width           column width, excel units (only makes sense once per column)
    header          boolean; is this cell a header?

Styles can be used to assign default values for any of these formatting
parameters thus allowing easy global changes. Other parameters specified
override style definitions.

Example:

  my $sp = Spreadsheet::Wright->new(
    file      => 'employees.xls',
    styles    => {
      important => { font_weight => 'bold' },
      },
    );
  $sp->addrow(
    { content => 'First Name', font_weight => 'bold' },
    { content => 'Last Name',  font_weight => 'bold' },
    { content => 'Age',        style => 'important' },
    );
  $sp->addrow("John", "Doe", 34);
  $sp->addrow("Susan", "Smith", 28);

Note that in this example all header cells will have identical
formatting even though some use direct formats and one uses
style.

If you want to store text that looks like a number you might want to use
{ type => 'string', format => '@' } arguments. By default the type detection
is automatic, as done by for instance L<Spreadsheet::WriteExcel> write()
method.

It is also possible to supply an array reference in the 'content'
parameter of the extended format. It means to use the same formatting
for as many cells as there are elements in this array. Useful for
creating header rows. For instance, the above example can be rewritten
as:

  $sp->addrow({
    style   => 'important',
    content => ['First Name', 'Last Name', 'Age'],
    });

Not all styling options are supported in all formats.

=item C<< addrows(\@row_1, \@row_2, ...) >>

Shortcut for adding multiple rows.

Each argument is an arrayref representing a row.

Any argument that is not a reference (i.e. a scalar) is taken to be the
title of a new worksheet.

=item C<< addsheet($name) >>

Adds a new sheet into the document and makes it active. Subsequent
addrow() calls will add rows to that new sheet.

For CSV format this call is NOT ignored, but produces a fatal error
currently.

=item C<< freeze($row, $col, $top_row, $left_col) >>

Sets a freeze-pane at the given position, equivalent to Spreadsheet::WriteExcel->freeze_panes().
Only implemented for Excel spreadsheets so far.

=item C<< close >>

Saves the spreadsheet to disk (some of the modules save incrementally anyway) and
closes the file. Calling this explicitly is usually un-necessary, as the Perl garbage collector
will do the job eventually anyway. Once a spreadsheet is closed, calls to addrow() will
fail.

=item C<< error >>

Returns the latest recoverable error.

=back

=head1 BUGS

Please report any bugs to L<http://rt.cpan.org/>.

=head1 SEE ALSO

L<Spreadsheet::Write>.

=head1 AUTHORS

Toby Inkster <tobyink@cpan.org>.

Excel and CSV output based almost entirely on work by
Nick Eremeev <nick.eremeev@gmail.com> L<http://ejelta.com/>.

=head1 COPYRIGHT AND LICENCE

Copyright 2007 Nick Eremeev.

Copyright 2010-2011 Toby Inkster.

This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

=head1 DISCLAIMER OF WARRANTIES

THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.