1Spreadsheet::ParseExcelU:s:eSravCeoPnatrrsiebru(t3e)d PeSrplreDaodcsuhmeeentt:a:tPiaornseExcel::SaveParser(3)
2
3
4
6 Spreadsheet::ParseExcel::SaveParser - Rewrite an existing Excel file.
7
9 #1. Write an Excel file with previous data
10 use strict;
11 use Spreadsheet::ParseExcel::SaveParser;
12 my $oExcel = new Spreadsheet::ParseExcel::SaveParser;
13 my $oBook = $oExcel->Parse('temp.xls');
14 #1.1.Update and Insert Cells
15 my $iFmt = $oBook->{Worksheet}[0]->{Cells}[0][0]->{FormatNo};
16 $oBook->AddCell(0, 0, 0, 'No(UPD)',
17 $oBook->{Worksheet}[0]->{Cells}[0][0]->{FormatNo});
18 $oBook->AddCell(0, 1, 0, '304', $oBook->{Worksheet}[0]->{Cells}[0][0]);
19 $oBook->AddCell(0, 1, 1, 'Kawai,Takanori', $iFmt);
20 #1.2.add new worksheet
21 my $iWkN = $oBook->AddWorksheet('Test');
22 #1.3 Save
23 $oExcel->SaveAs($oBook, 'temp.xls'); # as the same name
24 $oExcel->SaveAs($oBook, 'temp1.xls'); # another name
25
26 #2. Create new Excel file (most simple)
27 use strict;
28 use Spreadsheet::ParseExcel::SaveParser;
29 my $oEx = new Spreadsheet::ParseExcel::SaveParser;
30 my $oBook = $oEx->Create();
31 $oBook->AddFormat;
32 $oBook->AddWorksheet('NewWS');
33 $oBook->AddCell(0, 0, 1, 'New Cell');
34 $oEx->SaveAs($oBook, 'new.xls');
35
36 #3. Create new Excel file(more complex)
37 #!/usr/local/bin/perl
38 use strict;
39 use Spreadsheet::ParseExcel::SaveParser;
40 my $oEx = new Spreadsheet::ParseExcel::SaveParser;
41 my $oBook = $oEx->Create();
42 my $iF1 = $oBook->AddFont(
43 Name => 'Arial',
44 Height => 11,
45 Bold => 1, #Bold
46 Italic => 1, #Italic
47 Underline => 0,
48 Strikeout => 0,
49 Super => 0,
50 );
51 my $iFmt =
52 $oBook->AddFormat(
53 Font => $oBook->{Font}[$iF1],
54 Fill => [1, 10, 0], # Filled with Red
55 # cf. ParseExcel (@aColor)
56 BdrStyle => [0, 1, 1, 0], #Border Right, Top
57 BdrColor => [0, 11, 0, 0], # Right->Green
58 );
59 $oBook->AddWorksheet('NewWS');
60 $oBook->AddCell(0, 0, 1, 'Cell', $iFmt);
61 $oEx->SaveAs($oBook, 'new.xls');
62
63 new interface...
64
65 use strict;
66 use Spreadsheet::ParseExcel::SaveParser;
67 $oBook =
68 Spreadsheet::ParseExcel::SaveParser::Workbook->Parse('Excel/Test97.xls');
69 my $oWs = $oBook->AddWorksheet('TEST1');
70 $oWs->AddCell(10, 1, 'New Cell');
71 $oBook->SaveAs('iftest.xls');
72
74 Spreadsheet::ParseExcel::SaveParser : Expand of Spreadsheet::ParseExcel
75 with Spreadsheet::WriteExcel
76
77 Functions
78 new $oExcel = new Spreadsheet::ParseExcel::SaveParser();
79
80 Constructor.
81
82 Parse
83 $oWorkbook = $oParse->Parse($sFileName [, $oFmt]);
84
85 return "Workbook" object. if error occurs, returns undef.
86
87 $sFileName
88 name of the file to parse (Same as Spreadsheet::ParseExcel)
89
90 From 0.12 (with OLE::Storage_Lite v.0.06), scalar reference of
91 file contents (ex. \$sBuff) or IO::Handle object (inclucdng
92 IO::File etc.) are also available.
93
94 $oFmt
95 Formatter Class to format the value of cells.
96
97 Create
98 $oWorkbook = $oParse->Create([$oFmt]);
99
100 return new "Workbook" object. if error occurs, returns undef.
101
102 $oFmt
103 Formatter Class to format the value of cells.
104
105 SaveAs
106 $oWorkbook = $oParse->SaveAs( $oBook, $sName);
107
108 save $oBook image as an Excel file named $sName.
109
110 $oBook
111 An Excel Workbook object to save.
112
113 $sName
114 Name of new Excel file.
115
116 Workbook
117 Spreadsheet::ParseExcel::SaveParser::Workbook
118
119 Workbook is a subclass of Spreadsheet::ParseExcel::Workbook. And has
120 these methods :
121
122 AddWorksheet
123 $oWorksheet = $oBook->AddWorksheet($sName, %hProperty);
124
125 Create new Worksheet(Spreadsheet::ParseExcel::Worksheet).
126
127 $sName
128 Name of new Worksheet
129
130 $hProperty
131 Property of new Worksheet.
132
133 AddFont
134 $oWorksheet = $oBook->AddFont(%hProperty);
135
136 Create new Font(Spreadsheet::ParseExcel::Font).
137
138 $hProperty
139 Property of new Worksheet.
140
141 AddFormat
142 $oWorksheet = $oBook->AddFormat(%hProperty);
143
144 Create new Format(Spreadsheet::ParseExcel::Format).
145
146 $hProperty
147 Property of new Format.
148
149 AddCell
150 $oWorksheet = $oBook->AddCell($iWorksheet, $iRow, $iCol, $sVal,
151 $iFormat [, $sCode]);
152
153 Create new Cell(Spreadsheet::ParseExcel::Cell).
154
155 $iWorksheet
156 Number of Worksheet
157
158 $iRow
159 Number of row
160
161 $sVal
162 Value of the cell.
163
164 $iFormat
165 Number of format for use. To specify just same as another cell,
166 you can set it like below:
167
168 ex.
169
170 $oCell=$oWorksheet->{Cells}[0][0]; #Just a sample
171 $oBook->AddCell(0, 1, 0, 'New One', $oCell->{FormatNo});
172 #or
173 $oBook->AddCell(0, 1, 0, 'New One', $oCell);
174
175 $sCode
176 Character code
177
178 Worksheet
179 Spreadsheet::ParseExcel::SaveParser::Worksheet
180
181 Worksheet is a subclass of Spreadsheet::ParseExcel::Worksheet. And has
182 these methods :
183
184 AddCell
185 $oWorksheet = $oWkSheet->AddCell($iRow, $iCol, $sVal, $iFormat [,
186 $sCode]);
187
188 Create new Cell(Spreadsheet::ParseExcel::Cell).
189
190 $iRow
191 Number of row
192
193 $sVal
194 Value of the cell.
195
196 $iFormat
197 Number of format for use. To specify just same as another cell,
198 you can set it like below:
199
200 ex.
201
202 $oCell=$oWorksheet->{Cells}[0][0]; #Just a sample
203 $oWorksheet->AddCell(1, 0, 'New One', $oCell->{FormatNo});
204 #or
205 $oWorksheet->AddCell(1, 0, 'New One', $oCell);
206
207 $sCode
208 Character code
209
211 Please visit my Wiki page.
212 I'll add sample at :
213 http://www.hippo2000.info/cgi-bin/KbWikiE/KbWiki.pl
214
216 -Only last print area will remain. (Others will be removed)
217
219 Kawai Takanori (Hippo2000) kwitknr@cpan.org
220
221 http://member.nifty.ne.jp/hippo2000/ (Japanese)
222 http://member.nifty.ne.jp/hippo2000/index_e.htm (English)
223
225 XLHTML, OLE::Storage, Spreadsheet::WriteExcel, OLE::Storage_Lite
226
227 This module is based on herbert within OLE::Storage and XLHTML.
228
230 Copyright (c) 2009 John McNamara
231
232 Copyright (c) 2006-2008 Gabor Szabo
233
234 Copyright (c) 2000-2002 Kawai Takanori and Nippon-RAD Co. OP Division
235
236 All rights reserved.
237
238 You may distribute under the terms of either the GNU General Public
239 License or the Artistic License, as specified in the Perl README file.
240
242 First of all, I would like to acknowledge valuable program and modules
243 : XHTML, OLE::Storage and Spreadsheet::WriteExcel.
244
245 In no particular order: Yamaji Haruna, Simamoto Takesi, Noguchi Harumi,
246 Ikezawa Kazuhiro, Suwazono Shugo, Hirofumi Morisada, Michael Edwards,
247 Kim Namusk and many many people + Kawai Mikako.
248
249
250
251perl v5.12.0 2010-05S-p0r6eadsheet::ParseExcel::SaveParser(3)