This file is indexed.

/usr/share/perl5/Spreadsheet/ParseExcel/SaveParser.pm is in libspreadsheet-parseexcel-perl 0.5800-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
package Spreadsheet::ParseExcel::SaveParser;

###############################################################################
#
# Spreadsheet::ParseExcel::SaveParser - Rewrite an existing Excel file.
#
# Used in conjunction with Spreadsheet::ParseExcel.
#
# Copyright (c) 2009      John McNamara
# Copyright (c) 2006-2008 Gabor Szabo
# Copyright (c) 2000-2006 Kawai Takanori
#
# perltidy with standard settings.
#
# Documentation after __END__
#

use strict;
use warnings;

use Spreadsheet::ParseExcel;
use Spreadsheet::ParseExcel::SaveParser::Workbook;
use Spreadsheet::ParseExcel::SaveParser::Worksheet;
use Spreadsheet::WriteExcel;
use base 'Spreadsheet::ParseExcel';

our $VERSION = '0.58';

###############################################################################
#
# new()
#
sub new {

    my ( $package, %params ) = @_;
    $package->SUPER::new(%params);
}

###############################################################################
#
# Create()
#
sub Create {

    my ( $self, $formatter ) = @_;

    #0. New $workbook
    my $workbook = Spreadsheet::ParseExcel::Workbook->new();
    $workbook->{SheetCount} = 0;

    # User specified formater class.
    if ($formatter) {
        $workbook->{FmtClass} = $formatter;
    }
    else {
        $workbook->{FmtClass} = Spreadsheet::ParseExcel::FmtDefault->new();
    }

    return Spreadsheet::ParseExcel::SaveParser::Workbook->new($workbook);
}

###############################################################################
#
# Parse()
#
sub Parse {

    my ( $self, $sFile, $formatter ) = @_;

    my $workbook = $self->SUPER::Parse( $sFile, $formatter );

    return undef unless defined $workbook;
    return Spreadsheet::ParseExcel::SaveParser::Workbook->new($workbook);
}

###############################################################################
#
# SaveAs()
#
sub SaveAs {

    my ( $self, $workbook, $filename ) = @_;

    $workbook->SaveAs($filename);
}

1;

__END__

=head1 NAME

Spreadsheet::ParseExcel::SaveParser - Rewrite an existing Excel file.

=head1 SYNOPSIS



Say we start with an Excel file that looks like this:

    -----------------------------------------------------
   |   |      A      |      B      |      C      |
    -----------------------------------------------------
   | 1 | Hello       | ...         | ...         |  ...
   | 2 | World       | ...         | ...         |  ...
   | 3 | *Bold text* | ...         | ...         |  ...
   | 4 | ...         | ...         | ...         |  ...
   | 5 | ...         | ...         | ...         |  ...


Then we process it with the following program:

    #!/usr/bin/perl

    use strict;
    use warnings;

    use Spreadsheet::ParseExcel;
    use Spreadsheet::ParseExcel::SaveParser;


    # Open an existing file with SaveParser
    my $parser   = Spreadsheet::ParseExcel::SaveParser->new();
    my $template = $parser->Parse('template.xls');


    # Get the first worksheet.
    my $worksheet = $template->worksheet(0);
    my $row  = 0;
    my $col  = 0;


    # Overwrite the string in cell A1
    $worksheet->AddCell( $row, $col, 'New string' );


    # Add a new string in cell B1
    $worksheet->AddCell( $row, $col + 1, 'Newer' );


    # Add a new string in cell C1 with the format from cell A3.
    my $cell = $worksheet->get_cell( $row + 2, $col );
    my $format_number = $cell->{FormatNo};

    $worksheet->AddCell( $row, $col + 2, 'Newest', $format_number );


    # Write over the existing file or write a new file.
    $template->SaveAs('newfile.xls');


We should now have an Excel file that looks like this:

    -----------------------------------------------------
   |   |      A      |      B      |      C      |
    -----------------------------------------------------
   | 1 | New string  | Newer       | *Newest*    |  ...
   | 2 | World       | ...         | ...         |  ...
   | 3 | *Bold text* | ...         | ...         |  ...
   | 4 | ...         | ...         | ...         |  ...
   | 5 | ...         | ...         | ...         |  ...



=head1 DESCRIPTION

The C<Spreadsheet::ParseExcel::SaveParser> module rewrite an existing Excel file by reading it with C<Spreadsheet::ParseExcel> and rewriting it with C<Spreadsheet::WriteExcel>.

=head1 METHODS

=head1 Parser

=head2 new()

    $parse = new Spreadsheet::ParseExcel::SaveParser();

Constructor.

=head2 Parse()

    $workbook = $parse->Parse($sFileName);

    $workbook = $parse->Parse($sFileName , $formatter);

Returns a L</Workbook> object. If an error occurs, returns undef.

The optional C<$formatter> is a Formatter Class to format the value of cells.


=head1 Workbook

The C<Parse()> method returns a C<Spreadsheet::ParseExcel::SaveParser::Workbook> object.

This is a subclass of the L<Spreadsheet::ParseExcel::Workbook> and has the following methods:

=head2 worksheets()

Returns an array of L</Worksheet> objects. This was most commonly used to iterate over the worksheets in a workbook:

    for my $worksheet ( $workbook->worksheets() ) {
        ...
    }

=head2 worksheet()

The C<worksheet()> method returns a single C<Worksheet> object using either its name or index:

    $worksheet = $workbook->worksheet('Sheet1');
    $worksheet = $workbook->worksheet(0);

Returns C<undef> if the sheet name or index doesn't exist.


=head2 AddWorksheet()

    $workbook = $workbook->AddWorksheet($name, %properties);

Create a new Worksheet object of type C<Spreadsheet::ParseExcel::Worksheet>.

The C<%properties> hash contains the properties of new Worksheet.


=head2 AddFont

    $workbook = $workbook->AddFont(%properties);

Create new Font object of type C<Spreadsheet::ParseExcel::Font>.

The C<%properties> hash contains the properties of new Font.


=head2 AddFormat

    $workbook = $workbook->AddFormat(%properties);

The C<%properties> hash contains the properties of new Font.


=head1 Worksheet

Spreadsheet::ParseExcel::SaveParser::Worksheet

Worksheet is a subclass of Spreadsheet::ParseExcel::Worksheet.
And has these methods :


The C<Worksbook::worksheet()> method returns a C<Spreadsheet::ParseExcel::SaveParser::Worksheet> object.

This is a subclass of the L<Spreadsheet::ParseExcel::Worksheet> and has the following methods:


=head1 AddCell

    $workbook = $worksheet->AddCell($row, $col, $value, $format [$encoding]);

Create new Cell object of type C<Spreadsheet::ParseExcel::Cell>.

The C<$format> parameter is the format number rather than a full format object.

To specify just same as another cell,
you can set it like below:

    $row            = 0;
    $col            = 0;
    $worksheet      = $template->worksheet(0);
    $cell           = $worksheet->get_cell( $row, $col );
    $format_number  = $cell->{FormatNo};

    $worksheet->AddCell($row +1, $coll, 'New data', $format_number);




=head1 TODO

Please note that this module is currently (versions 0.50-0.60) undergoing a major
restructuring and rewriting.

=head1 Known Problems


You can only rewrite the features that Spreadsheet::WriteExcel supports so
macros, graphs and some other features in the original Excel file will be lost.
Also, formulas aren't rewritten, only the result of a formula is written.

Only last print area will remain. (Others will be removed)


=head1 AUTHOR

Maintainer 0.40+: John McNamara jmcnamara@cpan.org

Maintainer 0.27-0.33: Gabor Szabo szabgab@cpan.org

Original author: Kawai Takanori kwitknr@cpan.org

=head1 COPYRIGHT

Copyright (c) 2009-2010 John McNamara

Copyright (c) 2006-2008 Gabor Szabo

Copyright (c) 2000-2002 Kawai Takanori and Nippon-RAD Co. OP Division

All rights reserved.

You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file.


=cut