Subversion Repositories eFlore/Applications.cel

Rev

Rev 418 | Rev 1604 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 418 Rev 970
1
<?php
1
<?php
2
/*
2
/*
3
*  Module written/ported by Xavier Noguer <xnoguer@rezebra.com>
3
*  Module written/ported by Xavier Noguer <xnoguer@rezebra.com>
4
*
4
*
5
*  The majority of this is _NOT_ my code.  I simply ported it from the
5
*  The majority of this is _NOT_ my code.  I simply ported it from the
6
*  PERL Spreadsheet::WriteExcel module.
6
*  PERL Spreadsheet::WriteExcel module.
7
*
7
*
8
*  The author of the Spreadsheet::WriteExcel module is John McNamara 
8
*  The author of the Spreadsheet::WriteExcel module is John McNamara 
9
*  <jmcnamara@cpan.org>
9
*  <jmcnamara@cpan.org>
10
*
10
*
11
*  I _DO_ maintain this code, and John McNamara has nothing to do with the
11
*  I _DO_ maintain this code, and John McNamara has nothing to do with the
12
*  porting of this code to PHP.  Any questions directly related to this
12
*  porting of this code to PHP.  Any questions directly related to this
13
*  class library should be directed to me.
13
*  class library should be directed to me.
14
*
14
*
15
*  License Information:
15
*  License Information:
16
*
16
*
17
*    Spreadsheet_Excel_Writer:  A library for generating Excel Spreadsheets
17
*    Spreadsheet_Excel_Writer:  A library for generating Excel Spreadsheets
18
*    Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com
18
*    Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com
19
*
19
*
20
*    This library is free software; you can redistribute it and/or
20
*    This library is free software; you can redistribute it and/or
21
*    modify it under the terms of the GNU Lesser General Public
21
*    modify it under the terms of the GNU Lesser General Public
22
*    License as published by the Free Software Foundation; either
22
*    License as published by the Free Software Foundation; either
23
*    version 2.1 of the License, or (at your option) any later version.
23
*    version 2.1 of the License, or (at your option) any later version.
24
*
24
*
25
*    This library is distributed in the hope that it will be useful,
25
*    This library is distributed in the hope that it will be useful,
26
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
26
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
27
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
27
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
28
*    Lesser General Public License for more details.
28
*    Lesser General Public License for more details.
29
*
29
*
30
*    You should have received a copy of the GNU Lesser General Public
30
*    You should have received a copy of the GNU Lesser General Public
31
*    License along with this library; if not, write to the Free Software
31
*    License along with this library; if not, write to the Free Software
32
*    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
32
*    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
33
*/
33
*/
34
 
34
 
35
require_once('PEAR.php');
35
//require_once('PEAR.php');
36
 
36
 
37
/**
37
/**
38
* Class for generating Excel XF records (formats)
38
* Class for generating Excel XF records (formats)
39
*
39
*
40
* @author   Xavier Noguer <xnoguer@rezebra.com>
40
* @author   Xavier Noguer <xnoguer@rezebra.com>
41
* @category FileFormats
41
* @category FileFormats
42
* @package  Spreadsheet_Excel_Writer
42
* @package  Spreadsheet_Excel_Writer
43
*/
43
*/
44
 
44
 
45
class Spreadsheet_Excel_Writer_Format extends PEAR
45
class Spreadsheet_Excel_Writer_Format extends PEAR
46
{
46
{
47
    /**
47
    /**
48
    * The index given by the workbook when creating a new format.
48
    * The index given by the workbook when creating a new format.
49
    * @var integer
49
    * @var integer
50
    */
50
    */
51
    var $_xf_index;
51
    var $_xf_index;
52
 
52
 
53
    /**
53
    /**
54
    * Index to the FONT record.
54
    * Index to the FONT record.
55
    * @var integer
55
    * @var integer
56
    */
56
    */
57
    var $font_index;
57
    var $font_index;
58
 
58
 
59
    /**
59
    /**
60
    * The font name (ASCII).
60
    * The font name (ASCII).
61
    * @var string
61
    * @var string
62
    */
62
    */
63
    var $_font_name;
63
    var $_font_name;
64
 
64
 
65
    /**
65
    /**
66
    * Height of font (1/20 of a point)
66
    * Height of font (1/20 of a point)
67
    * @var integer
67
    * @var integer
68
    */
68
    */
69
    var $_size;
69
    var $_size;
70
 
70
 
71
    /**
71
    /**
72
    * Bold style
72
    * Bold style
73
    * @var integer
73
    * @var integer
74
    */
74
    */
75
    var $_bold;
75
    var $_bold;
76
 
76
 
77
    /**
77
    /**
78
    * Bit specifiying if the font is italic.
78
    * Bit specifiying if the font is italic.
79
    * @var integer
79
    * @var integer
80
    */
80
    */
81
    var $_italic;
81
    var $_italic;
82
 
82
 
83
    /**
83
    /**
84
    * Index to the cell's color
84
    * Index to the cell's color
85
    * @var integer
85
    * @var integer
86
    */
86
    */
87
    var $_color;
87
    var $_color;
88
 
88
 
89
    /**
89
    /**
90
    * The text underline property
90
    * The text underline property
91
    * @var integer
91
    * @var integer
92
    */
92
    */
93
    var $_underline;
93
    var $_underline;
94
 
94
 
95
    /**
95
    /**
96
    * Bit specifiying if the font has strikeout.
96
    * Bit specifiying if the font has strikeout.
97
    * @var integer
97
    * @var integer
98
    */
98
    */
99
    var $_font_strikeout;
99
    var $_font_strikeout;
100
 
100
 
101
    /**
101
    /**
102
    * Bit specifiying if the font has outline.
102
    * Bit specifiying if the font has outline.
103
    * @var integer
103
    * @var integer
104
    */
104
    */
105
    var $_font_outline;
105
    var $_font_outline;
106
 
106
 
107
    /**
107
    /**
108
    * Bit specifiying if the font has shadow.
108
    * Bit specifiying if the font has shadow.
109
    * @var integer
109
    * @var integer
110
    */
110
    */
111
    var $_font_shadow;
111
    var $_font_shadow;
112
 
112
 
113
    /**
113
    /**
114
    * 2 bytes specifiying the script type for the font.
114
    * 2 bytes specifiying the script type for the font.
115
    * @var integer
115
    * @var integer
116
    */
116
    */
117
    var $_font_script;
117
    var $_font_script;
118
 
118
 
119
    /**
119
    /**
120
    * Byte specifiying the font family.
120
    * Byte specifiying the font family.
121
    * @var integer
121
    * @var integer
122
    */
122
    */
123
    var $_font_family;
123
    var $_font_family;
124
 
124
 
125
    /**
125
    /**
126
    * Byte specifiying the font charset.
126
    * Byte specifiying the font charset.
127
    * @var integer
127
    * @var integer
128
    */
128
    */
129
    var $_font_charset;
129
    var $_font_charset;
130
 
130
 
131
    /**
131
    /**
132
    * An index (2 bytes) to a FORMAT record (number format).
132
    * An index (2 bytes) to a FORMAT record (number format).
133
    * @var integer
133
    * @var integer
134
    */
134
    */
135
    var $_num_format;
135
    var $_num_format;
136
 
136
 
137
    /**
137
    /**
138
    * Bit specifying if formulas are hidden.
138
    * Bit specifying if formulas are hidden.
139
    * @var integer
139
    * @var integer
140
    */
140
    */
141
    var $_hidden;
141
    var $_hidden;
142
 
142
 
143
    /**
143
    /**
144
    * Bit specifying if the cell is locked.
144
    * Bit specifying if the cell is locked.
145
    * @var integer
145
    * @var integer
146
    */
146
    */
147
    var $_locked;
147
    var $_locked;
148
 
148
 
149
    /**
149
    /**
150
    * The three bits specifying the text horizontal alignment.
150
    * The three bits specifying the text horizontal alignment.
151
    * @var integer
151
    * @var integer
152
    */
152
    */
153
    var $_text_h_align;
153
    var $_text_h_align;
154
 
154
 
155
    /**
155
    /**
156
    * Bit specifying if the text is wrapped at the right border.
156
    * Bit specifying if the text is wrapped at the right border.
157
    * @var integer
157
    * @var integer
158
    */
158
    */
159
    var $_text_wrap;
159
    var $_text_wrap;
160
 
160
 
161
    /**
161
    /**
162
    * The three bits specifying the text vertical alignment.
162
    * The three bits specifying the text vertical alignment.
163
    * @var integer
163
    * @var integer
164
    */
164
    */
165
    var $_text_v_align;
165
    var $_text_v_align;
166
 
166
 
167
    /**
167
    /**
168
    * 1 bit, apparently not used.
168
    * 1 bit, apparently not used.
169
    * @var integer
169
    * @var integer
170
    */
170
    */
171
    var $_text_justlast;
171
    var $_text_justlast;
172
 
172
 
173
    /**
173
    /**
174
    * The two bits specifying the text rotation.
174
    * The two bits specifying the text rotation.
175
    * @var integer
175
    * @var integer
176
    */
176
    */
177
    var $_rotation;
177
    var $_rotation;
178
 
178
 
179
    /**
179
    /**
180
    * The cell's foreground color.
180
    * The cell's foreground color.
181
    * @var integer
181
    * @var integer
182
    */
182
    */
183
    var $_fg_color;
183
    var $_fg_color;
184
 
184
 
185
    /**
185
    /**
186
    * The cell's background color.
186
    * The cell's background color.
187
    * @var integer
187
    * @var integer
188
    */
188
    */
189
    var $_bg_color;
189
    var $_bg_color;
190
 
190
 
191
    /**
191
    /**
192
    * The cell's background fill pattern.
192
    * The cell's background fill pattern.
193
    * @var integer
193
    * @var integer
194
    */
194
    */
195
    var $_pattern;
195
    var $_pattern;
196
 
196
 
197
    /**
197
    /**
198
    * Style of the bottom border of the cell
198
    * Style of the bottom border of the cell
199
    * @var integer
199
    * @var integer
200
    */
200
    */
201
    var $_bottom;
201
    var $_bottom;
202
 
202
 
203
    /**
203
    /**
204
    * Color of the bottom border of the cell.
204
    * Color of the bottom border of the cell.
205
    * @var integer
205
    * @var integer
206
    */
206
    */
207
    var $_bottom_color;
207
    var $_bottom_color;
208
 
208
 
209
    /**
209
    /**
210
    * Style of the top border of the cell
210
    * Style of the top border of the cell
211
    * @var integer
211
    * @var integer
212
    */
212
    */
213
    var $_top;
213
    var $_top;
214
 
214
 
215
    /**
215
    /**
216
    * Color of the top border of the cell.
216
    * Color of the top border of the cell.
217
    * @var integer
217
    * @var integer
218
    */
218
    */
219
    var $_top_color;
219
    var $_top_color;
220
 
220
 
221
    /**
221
    /**
222
    * Style of the left border of the cell
222
    * Style of the left border of the cell
223
    * @var integer
223
    * @var integer
224
    */
224
    */
225
    var $_left;
225
    var $_left;
226
 
226
 
227
    /**
227
    /**
228
    * Color of the left border of the cell.
228
    * Color of the left border of the cell.
229
    * @var integer
229
    * @var integer
230
    */
230
    */
231
    var $_left_color;
231
    var $_left_color;
232
 
232
 
233
    /**
233
    /**
234
    * Style of the right border of the cell
234
    * Style of the right border of the cell
235
    * @var integer
235
    * @var integer
236
    */
236
    */
237
    var $_right;
237
    var $_right;
238
 
238
 
239
    /**
239
    /**
240
    * Color of the right border of the cell.
240
    * Color of the right border of the cell.
241
    * @var integer
241
    * @var integer
242
    */
242
    */
243
    var $_right_color;
243
    var $_right_color;
244
 
244
 
245
    /**
245
    /**
246
    * Constructor
246
    * Constructor
247
    *
247
    *
248
    * @access public
248
    * @access public
249
    * @param integer $index the XF index for the format.
249
    * @param integer $index the XF index for the format.
250
    * @param array   $properties array with properties to be set on initialization.
250
    * @param array   $properties array with properties to be set on initialization.
251
    */
251
    */
252
    function Spreadsheet_Excel_Writer_Format($index = 0,$properties =  array())
252
    function Spreadsheet_Excel_Writer_Format($index = 0,$properties =  array())
253
    {
253
    {
254
        $this->_xf_index       = $index;
254
        $this->_xf_index       = $index;
255
                               
255
                               
256
        $this->font_index      = 0;
256
        $this->font_index      = 0;
257
        $this->_font_name      = 'Arial';
257
        $this->_font_name      = 'Arial';
258
        $this->_size           = 10;
258
        $this->_size           = 10;
259
        $this->_bold           = 0x0190;
259
        $this->_bold           = 0x0190;
260
        $this->_italic         = 0;
260
        $this->_italic         = 0;
261
        $this->_color          = 0x7FFF;
261
        $this->_color          = 0x7FFF;
262
        $this->_underline      = 0;
262
        $this->_underline      = 0;
263
        $this->_font_strikeout = 0;
263
        $this->_font_strikeout = 0;
264
        $this->_font_outline   = 0;
264
        $this->_font_outline   = 0;
265
        $this->_font_shadow    = 0;
265
        $this->_font_shadow    = 0;
266
        $this->_font_script    = 0;
266
        $this->_font_script    = 0;
267
        $this->_font_family    = 0;
267
        $this->_font_family    = 0;
268
        $this->_font_charset   = 0;
268
        $this->_font_charset   = 0;
269
                               
269
                               
270
        $this->_num_format     = 0;
270
        $this->_num_format     = 0;
271
                               
271
                               
272
        $this->_hidden         = 0;
272
        $this->_hidden         = 0;
273
        $this->_locked         = 1;
273
        $this->_locked         = 1;
274
 
274
 
275
        $this->_text_h_align   = 0;
275
        $this->_text_h_align   = 0;
276
        $this->_text_wrap      = 0;
276
        $this->_text_wrap      = 0;
277
        $this->_text_v_align   = 2;
277
        $this->_text_v_align   = 2;
278
        $this->_text_justlast  = 0;
278
        $this->_text_justlast  = 0;
279
        $this->_rotation       = 0;
279
        $this->_rotation       = 0;
280
 
280
 
281
        $this->_fg_color       = 0x40;
281
        $this->_fg_color       = 0x40;
282
        $this->_bg_color       = 0x41;
282
        $this->_bg_color       = 0x41;
283
 
283
 
284
        $this->_pattern        = 0;
284
        $this->_pattern        = 0;
285
                               
285
                               
286
        $this->_bottom         = 0;
286
        $this->_bottom         = 0;
287
        $this->_top            = 0;
287
        $this->_top            = 0;
288
        $this->_left           = 0;
288
        $this->_left           = 0;
289
        $this->_right          = 0;
289
        $this->_right          = 0;
290
                               
290
                               
291
        $this->_bottom_color   = 0x40;
291
        $this->_bottom_color   = 0x40;
292
        $this->_top_color      = 0x40;
292
        $this->_top_color      = 0x40;
293
        $this->_left_color     = 0x40;
293
        $this->_left_color     = 0x40;
294
        $this->_right_color    = 0x40;
294
        $this->_right_color    = 0x40;
295
    
295
    
296
        // Set properties passed to Spreadsheet_Excel_Writer_Workbook::addFormat()
296
        // Set properties passed to Spreadsheet_Excel_Writer_Workbook::addFormat()
297
        foreach($properties as $property => $value)
297
        foreach($properties as $property => $value)
298
        {
298
        {
299
            if(method_exists($this,'set'.ucwords($property)))
299
            if(method_exists($this,'set'.ucwords($property)))
300
            {
300
            {
301
                $method_name = 'set'.ucwords($property);
301
                $method_name = 'set'.ucwords($property);
302
                $this->$method_name($value);
302
                $this->$method_name($value);
303
            }
303
            }
304
        }
304
        }
305
    }
305
    }
306
 
306
 
307
 
307
 
308
    /**
308
    /**
309
    * Generate an Excel BIFF XF record (style or cell).
309
    * Generate an Excel BIFF XF record (style or cell).
310
    *
310
    *
311
    * @param string $style The type of the XF record ('style' or 'cell').
311
    * @param string $style The type of the XF record ('style' or 'cell').
312
    * @return string The XF record
312
    * @return string The XF record
313
    */
313
    */
314
    function getXf($style)
314
    function getXf($style)
315
    {
315
    {
316
        // Set the type of the XF record and some of the attributes.
316
        // Set the type of the XF record and some of the attributes.
317
        if ($style == "style") {
317
        if ($style == "style") {
318
            $style = 0xFFF5;
318
            $style = 0xFFF5;
319
        }
319
        }
320
        else {
320
        else {
321
            $style   = $this->_locked;
321
            $style   = $this->_locked;
322
            $style  |= $this->_hidden << 1;
322
            $style  |= $this->_hidden << 1;
323
        }
323
        }
324
    
324
    
325
        // Flags to indicate if attributes have been set.
325
        // Flags to indicate if attributes have been set.
326
        $atr_num     = ($this->_num_format != 0)?1:0;
326
        $atr_num     = ($this->_num_format != 0)?1:0;
327
        $atr_fnt     = ($this->font_index != 0)?1:0;
327
        $atr_fnt     = ($this->font_index != 0)?1:0;
328
        $atr_alc     = ($this->_text_wrap)?1:0;
328
        $atr_alc     = ($this->_text_wrap)?1:0;
329
        $atr_bdr     = ($this->_bottom   ||
329
        $atr_bdr     = ($this->_bottom   ||
330
                        $this->_top      ||
330
                        $this->_top      ||
331
                        $this->_left     ||
331
                        $this->_left     ||
332
                        $this->_right)?1:0;
332
                        $this->_right)?1:0;
333
        $atr_pat     = (($this->_fg_color != 0x40) ||
333
        $atr_pat     = (($this->_fg_color != 0x40) ||
334
                        ($this->_bg_color != 0x41) ||
334
                        ($this->_bg_color != 0x41) ||
335
                        $this->_pattern)?1:0;
335
                        $this->_pattern)?1:0;
336
        $atr_prot    = 0;
336
        $atr_prot    = 0;
337
    
337
    
338
        // Zero the default border colour if the border has not been set.
338
        // Zero the default border colour if the border has not been set.
339
        if ($this->_bottom == 0) {
339
        if ($this->_bottom == 0) {
340
            $this->_bottom_color = 0;
340
            $this->_bottom_color = 0;
341
            }
341
            }
342
        if ($this->_top  == 0) {
342
        if ($this->_top  == 0) {
343
            $this->_top_color = 0;
343
            $this->_top_color = 0;
344
            }
344
            }
345
        if ($this->_right == 0) {
345
        if ($this->_right == 0) {
346
            $this->_right_color = 0;
346
            $this->_right_color = 0;
347
            }
347
            }
348
        if ($this->_left == 0) {
348
        if ($this->_left == 0) {
349
            $this->_left_color = 0;
349
            $this->_left_color = 0;
350
            }
350
            }
351
    
351
    
352
        $record         = 0x00E0;              // Record identifier
352
        $record         = 0x00E0;              // Record identifier
353
        $length         = 0x0010;              // Number of bytes to follow
353
        $length         = 0x0010;              // Number of bytes to follow
354
                                               
354
                                               
355
        $ifnt           = $this->font_index;   // Index to FONT record
355
        $ifnt           = $this->font_index;   // Index to FONT record
356
        $ifmt           = $this->_num_format;  // Index to FORMAT record
356
        $ifmt           = $this->_num_format;  // Index to FORMAT record
357
    
357
    
358
        $align          = $this->_text_h_align;       // Alignment
358
        $align          = $this->_text_h_align;       // Alignment
359
        $align         |= $this->_text_wrap     << 3;
359
        $align         |= $this->_text_wrap     << 3;
360
        $align         |= $this->_text_v_align  << 4;
360
        $align         |= $this->_text_v_align  << 4;
361
        $align         |= $this->_text_justlast << 7;
361
        $align         |= $this->_text_justlast << 7;
362
        $align         |= $this->_rotation      << 8;
362
        $align         |= $this->_rotation      << 8;
363
        $align         |= $atr_num                << 10;
363
        $align         |= $atr_num                << 10;
364
        $align         |= $atr_fnt                << 11;
364
        $align         |= $atr_fnt                << 11;
365
        $align         |= $atr_alc                << 12;
365
        $align         |= $atr_alc                << 12;
366
        $align         |= $atr_bdr                << 13;
366
        $align         |= $atr_bdr                << 13;
367
        $align         |= $atr_pat                << 14;
367
        $align         |= $atr_pat                << 14;
368
        $align         |= $atr_prot               << 15;
368
        $align         |= $atr_prot               << 15;
369
    
369
    
370
        $icv            = $this->_fg_color;           // fg and bg pattern colors
370
        $icv            = $this->_fg_color;           // fg and bg pattern colors
371
        $icv           |= $this->_bg_color      << 7;
371
        $icv           |= $this->_bg_color      << 7;
372
    
372
    
373
        $fill           = $this->_pattern;            // Fill and border line style
373
        $fill           = $this->_pattern;            // Fill and border line style
374
        $fill          |= $this->_bottom        << 6;
374
        $fill          |= $this->_bottom        << 6;
375
        $fill          |= $this->_bottom_color  << 9;
375
        $fill          |= $this->_bottom_color  << 9;
376
    
376
    
377
        $border1        = $this->_top;                // Border line style and color
377
        $border1        = $this->_top;                // Border line style and color
378
        $border1       |= $this->_left          << 3;
378
        $border1       |= $this->_left          << 3;
379
        $border1       |= $this->_right         << 6;
379
        $border1       |= $this->_right         << 6;
380
        $border1       |= $this->_top_color     << 9;
380
        $border1       |= $this->_top_color     << 9;
381
    
381
    
382
        $border2        = $this->_left_color;         // Border color
382
        $border2        = $this->_left_color;         // Border color
383
        $border2       |= $this->_right_color   << 7;
383
        $border2       |= $this->_right_color   << 7;
384
    
384
    
385
        $header      = pack("vv",       $record, $length);
385
        $header      = pack("vv",       $record, $length);
386
        $data        = pack("vvvvvvvv", $ifnt, $ifmt, $style, $align,
386
        $data        = pack("vvvvvvvv", $ifnt, $ifmt, $style, $align,
387
                                        $icv, $fill,
387
                                        $icv, $fill,
388
                                        $border1, $border2);
388
                                        $border1, $border2);
389
        return($header.$data);
389
        return($header.$data);
390
    }
390
    }
391
    
391
    
392
    /**
392
    /**
393
    * Generate an Excel BIFF FONT record.
393
    * Generate an Excel BIFF FONT record.
394
    *
394
    *
395
    * @return string The FONT record
395
    * @return string The FONT record
396
    */
396
    */
397
    function getFont()
397
    function getFont()
398
    {
398
    {
399
        $dyHeight   = $this->_size * 20;    // Height of font (1/20 of a point)
399
        $dyHeight   = $this->_size * 20;    // Height of font (1/20 of a point)
400
        $icv        = $this->_color;        // Index to color palette
400
        $icv        = $this->_color;        // Index to color palette
401
        $bls        = $this->_bold;         // Bold style
401
        $bls        = $this->_bold;         // Bold style
402
        $sss        = $this->_font_script;  // Superscript/subscript
402
        $sss        = $this->_font_script;  // Superscript/subscript
403
        $uls        = $this->_underline;    // Underline
403
        $uls        = $this->_underline;    // Underline
404
        $bFamily    = $this->_font_family;  // Font family
404
        $bFamily    = $this->_font_family;  // Font family
405
        $bCharSet   = $this->_font_charset; // Character set
405
        $bCharSet   = $this->_font_charset; // Character set
406
        $rgch       = $this->_font_name;    // Font name
406
        $rgch       = $this->_font_name;    // Font name
407
    
407
    
408
        $cch        = strlen($rgch);       // Length of font name
408
        $cch        = strlen($rgch);       // Length of font name
409
        $record     = 0x31;                // Record identifier
409
        $record     = 0x31;                // Record identifier
410
        $length     = 0x0F + $cch;         // Record length
410
        $length     = 0x0F + $cch;         // Record length
411
        $reserved   = 0x00;                // Reserved
411
        $reserved   = 0x00;                // Reserved
412
        $grbit      = 0x00;                // Font attributes
412
        $grbit      = 0x00;                // Font attributes
413
        if ($this->_italic) {
413
        if ($this->_italic) {
414
            $grbit     |= 0x02;
414
            $grbit     |= 0x02;
415
        }
415
        }
416
        if ($this->_font_strikeout) {
416
        if ($this->_font_strikeout) {
417
            $grbit     |= 0x08;
417
            $grbit     |= 0x08;
418
        }
418
        }
419
        if ($this->_font_outline) {
419
        if ($this->_font_outline) {
420
            $grbit     |= 0x10;
420
            $grbit     |= 0x10;
421
        }
421
        }
422
        if ($this->_font_shadow) {
422
        if ($this->_font_shadow) {
423
            $grbit     |= 0x20;
423
            $grbit     |= 0x20;
424
        }
424
        }
425
    
425
    
426
        $header  = pack("vv",         $record, $length);
426
        $header  = pack("vv",         $record, $length);
427
        $data    = pack("vvvvvCCCCC", $dyHeight, $grbit, $icv, $bls,
427
        $data    = pack("vvvvvCCCCC", $dyHeight, $grbit, $icv, $bls,
428
                                      $sss, $uls, $bFamily,
428
                                      $sss, $uls, $bFamily,
429
                                      $bCharSet, $reserved, $cch);
429
                                      $bCharSet, $reserved, $cch);
430
        return($header . $data. $this->_font_name);
430
        return($header . $data. $this->_font_name);
431
    }
431
    }
432
    
432
    
433
    /**
433
    /**
434
    * Returns a unique hash key for a font. 
434
    * Returns a unique hash key for a font. 
435
    * Used by Spreadsheet_Excel_Writer_Workbook::_storeAllFonts()
435
    * Used by Spreadsheet_Excel_Writer_Workbook::_storeAllFonts()
436
    *
436
    *
437
    * The elements that form the key are arranged to increase the probability of
437
    * The elements that form the key are arranged to increase the probability of
438
    * generating a unique key. Elements that hold a large range of numbers
438
    * generating a unique key. Elements that hold a large range of numbers
439
    * (eg. _color) are placed between two binary elements such as _italic
439
    * (eg. _color) are placed between two binary elements such as _italic
440
    *
440
    *
441
    * @return string A key for this font
441
    * @return string A key for this font
442
    */
442
    */
443
    function getFontKey()
443
    function getFontKey()
444
    {
444
    {
445
        $key  = "$this->_font_name$this->_size";
445
        $key  = "$this->_font_name$this->_size";
446
        $key .= "$this->_font_script$this->_underline";
446
        $key .= "$this->_font_script$this->_underline";
447
        $key .= "$this->_font_strikeout$this->_bold$this->_font_outline";
447
        $key .= "$this->_font_strikeout$this->_bold$this->_font_outline";
448
        $key .= "$this->_font_family$this->_font_charset";
448
        $key .= "$this->_font_family$this->_font_charset";
449
        $key .= "$this->_font_shadow$this->_color$this->_italic";
449
        $key .= "$this->_font_shadow$this->_color$this->_italic";
450
        $key  = str_replace(" ","_",$key);
450
        $key  = str_replace(" ","_",$key);
451
        return ($key);
451
        return ($key);
452
    }
452
    }
453
    
453
    
454
    /**
454
    /**
455
    * Returns the index used by Spreadsheet_Excel_Writer_Worksheet::_XF()
455
    * Returns the index used by Spreadsheet_Excel_Writer_Worksheet::_XF()
456
    *
456
    *
457
    * @return integer The index for the XF record
457
    * @return integer The index for the XF record
458
    */
458
    */
459
    function getXfIndex()
459
    function getXfIndex()
460
    {
460
    {
461
        return($this->_xf_index);
461
        return($this->_xf_index);
462
    }
462
    }
463
    
463
    
464
    /**
464
    /**
465
    * Used in conjunction with the set_xxx_color methods to convert a color
465
    * Used in conjunction with the set_xxx_color methods to convert a color
466
    * string into a number. Color range is 0..63 but we will restrict it
466
    * string into a number. Color range is 0..63 but we will restrict it
467
    * to 8..63 to comply with Gnumeric. Colors 0..7 are repeated in 8..15.
467
    * to 8..63 to comply with Gnumeric. Colors 0..7 are repeated in 8..15.
468
    *
468
    *
469
    * @access private
469
    * @access private
470
    * @param string $name_color name of the color (i.e.: 'blue', 'red', etc..). Optional.
470
    * @param string $name_color name of the color (i.e.: 'blue', 'red', etc..). Optional.
471
    * @return integer The color index
471
    * @return integer The color index
472
    */
472
    */
473
    function _getColor($name_color = '')
473
    function _getColor($name_color = '')
474
    {
474
    {
475
        $colors = array(
475
        $colors = array(
476
                        'aqua'    => 0x0F,
476
                        'aqua'    => 0x0F,
477
                        'cyan'    => 0x0F,
477
                        'cyan'    => 0x0F,
478
                        'black'   => 0x08,
478
                        'black'   => 0x08,
479
                        'blue'    => 0x0C,
479
                        'blue'    => 0x0C,
480
                        'brown'   => 0x10,
480
                        'brown'   => 0x10,
481
                        'magenta' => 0x0E,
481
                        'magenta' => 0x0E,
482
                        'fuchsia' => 0x0E,
482
                        'fuchsia' => 0x0E,
483
                        'gray'    => 0x17,
483
                        'gray'    => 0x17,
484
                        'grey'    => 0x17,
484
                        'grey'    => 0x17,
485
                        'green'   => 0x11,
485
                        'green'   => 0x11,
486
                        'lime'    => 0x0B,
486
                        'lime'    => 0x0B,
487
                        'navy'    => 0x12,
487
                        'navy'    => 0x12,
488
                        'orange'  => 0x35,
488
                        'orange'  => 0x35,
489
                        'purple'  => 0x14,
489
                        'purple'  => 0x14,
490
                        'red'     => 0x0A,
490
                        'red'     => 0x0A,
491
                        'silver'  => 0x16,
491
                        'silver'  => 0x16,
492
                        'white'   => 0x09,
492
                        'white'   => 0x09,
493
                        'yellow'  => 0x0D
493
                        'yellow'  => 0x0D
494
                       );
494
                       );
495
    
495
    
496
        // Return the default color, 0x7FFF, if undef,
496
        // Return the default color, 0x7FFF, if undef,
497
        if($name_color == '') {
497
        if($name_color == '') {
498
            return(0x7FFF);
498
            return(0x7FFF);
499
        }
499
        }
500
    
500
    
501
        // or the color string converted to an integer,
501
        // or the color string converted to an integer,
502
        if(isset($colors[$name_color])) {
502
        if(isset($colors[$name_color])) {
503
            return($colors[$name_color]);
503
            return($colors[$name_color]);
504
        }
504
        }
505
    
505
    
506
        // or the default color if string is unrecognised,
506
        // or the default color if string is unrecognised,
507
        if(preg_match("/\D/",$name_color)) {
507
        if(preg_match("/\D/",$name_color)) {
508
            return(0x7FFF);
508
            return(0x7FFF);
509
        }
509
        }
510
    
510
    
511
        // or an index < 8 mapped into the correct range,
511
        // or an index < 8 mapped into the correct range,
512
        if($name_color < 8) {
512
        if($name_color < 8) {
513
            return($name_color + 8);
513
            return($name_color + 8);
514
        }
514
        }
515
    
515
    
516
        // or the default color if arg is outside range,
516
        // or the default color if arg is outside range,
517
        if($name_color > 63) {
517
        if($name_color > 63) {
518
            return(0x7FFF);
518
            return(0x7FFF);
519
        }
519
        }
520
    
520
    
521
        // or an integer in the valid range
521
        // or an integer in the valid range
522
        return($name_color);
522
        return($name_color);
523
    }
523
    }
524
    
524
    
525
    /**
525
    /**
526
    * Set cell alignment.
526
    * Set cell alignment.
527
    *
527
    *
528
    * @access public
528
    * @access public
529
    * @param string $location alignment for the cell ('left', 'right', etc...).
529
    * @param string $location alignment for the cell ('left', 'right', etc...).
530
    */
530
    */
531
    function setAlign($location)
531
    function setAlign($location)
532
    {
532
    {
533
        if (preg_match("/\d/",$location)) {
533
        if (preg_match("/\d/",$location)) {
534
            return;                      // Ignore numbers
534
            return;                      // Ignore numbers
535
        }
535
        }
536
    
536
    
537
        $location = strtolower($location);
537
        $location = strtolower($location);
538
    
538
    
539
        if ($location == 'left') {
539
        if ($location == 'left') {
540
            $this->_text_h_align = 1;
540
            $this->_text_h_align = 1;
541
            }
541
            }
542
        if ($location == 'centre') {
542
        if ($location == 'centre') {
543
            $this->_text_h_align = 2;
543
            $this->_text_h_align = 2;
544
            }
544
            }
545
        if ($location == 'center') {
545
        if ($location == 'center') {
546
            $this->_text_h_align = 2;
546
            $this->_text_h_align = 2;
547
            }
547
            }
548
        if ($location == 'right') {
548
        if ($location == 'right') {
549
            $this->_text_h_align = 3;
549
            $this->_text_h_align = 3;
550
            }
550
            }
551
        if ($location == 'fill') {
551
        if ($location == 'fill') {
552
            $this->_text_h_align = 4;
552
            $this->_text_h_align = 4;
553
            }
553
            }
554
        if ($location == 'justify') {
554
        if ($location == 'justify') {
555
            $this->_text_h_align = 5;
555
            $this->_text_h_align = 5;
556
            }
556
            }
557
        if ($location == 'merge') {
557
        if ($location == 'merge') {
558
            $this->_text_h_align = 6;
558
            $this->_text_h_align = 6;
559
            }
559
            }
560
        if ($location == 'equal_space') { // For T.K.
560
        if ($location == 'equal_space') { // For T.K.
561
            $this->_text_h_align = 7;
561
            $this->_text_h_align = 7;
562
            }
562
            }
563
        if ($location == 'top') {
563
        if ($location == 'top') {
564
            $this->_text_v_align = 0;
564
            $this->_text_v_align = 0;
565
            }
565
            }
566
        if ($location == 'vcentre') {
566
        if ($location == 'vcentre') {
567
            $this->_text_v_align = 1;
567
            $this->_text_v_align = 1;
568
            }
568
            }
569
        if ($location == 'vcenter') {
569
        if ($location == 'vcenter') {
570
            $this->_text_v_align = 1;
570
            $this->_text_v_align = 1;
571
            }
571
            }
572
        if ($location == 'bottom') {
572
        if ($location == 'bottom') {
573
            $this->_text_v_align = 2;
573
            $this->_text_v_align = 2;
574
            }
574
            }
575
        if ($location == 'vjustify') {
575
        if ($location == 'vjustify') {
576
            $this->_text_v_align = 3;
576
            $this->_text_v_align = 3;
577
            }
577
            }
578
        if ($location == 'vequal_space') { // For T.K.
578
        if ($location == 'vequal_space') { // For T.K.
579
            $this->_text_v_align = 4;
579
            $this->_text_v_align = 4;
580
            }
580
            }
581
    }
581
    }
582
    
582
    
583
    /**
583
    /**
584
    * This is an alias for the unintuitive setAlign('merge')
584
    * This is an alias for the unintuitive setAlign('merge')
585
    *
585
    *
586
    * @access public
586
    * @access public
587
    */
587
    */
588
    function setMerge()
588
    function setMerge()
589
    {
589
    {
590
        $this->setAlign('merge');
590
        $this->setAlign('merge');
591
    }
591
    }
592
    
592
    
593
    /**
593
    /**
594
    * Sets the boldness of the text.
594
    * Sets the boldness of the text.
595
    * Bold has a range 100..1000.
595
    * Bold has a range 100..1000.
596
    * 0 (400) is normal. 1 (700) is bold.
596
    * 0 (400) is normal. 1 (700) is bold.
597
    *
597
    *
598
    * @access public
598
    * @access public
599
    * @param integer $weight Weight for the text, 0 maps to 400 (normal text),
599
    * @param integer $weight Weight for the text, 0 maps to 400 (normal text),
600
                             1 maps to 700 (bold text). Valid range is: 100-1000.
600
                             1 maps to 700 (bold text). Valid range is: 100-1000.
601
                             It's Optional, default is 1 (bold).
601
                             It's Optional, default is 1 (bold).
602
    */
602
    */
603
    function setBold($weight = 1)
603
    function setBold($weight = 1)
604
    {
604
    {
605
        if($weight == 1) {
605
        if($weight == 1) {
606
            $weight = 0x2BC;  // Bold text
606
            $weight = 0x2BC;  // Bold text
607
        }
607
        }
608
        if($weight == 0) {
608
        if($weight == 0) {
609
            $weight = 0x190;  // Normal text
609
            $weight = 0x190;  // Normal text
610
        }
610
        }
611
        if($weight <  0x064) {
611
        if($weight <  0x064) {
612
            $weight = 0x190;  // Lower bound
612
            $weight = 0x190;  // Lower bound
613
        }
613
        }
614
        if($weight >  0x3E8) {
614
        if($weight >  0x3E8) {
615
            $weight = 0x190;  // Upper bound
615
            $weight = 0x190;  // Upper bound
616
        }
616
        }
617
        $this->_bold = $weight;
617
        $this->_bold = $weight;
618
    }
618
    }
619
    
619
    
620
    
620
    
621
    /************************************
621
    /************************************
622
    * FUNCTIONS FOR SETTING CELLS BORDERS
622
    * FUNCTIONS FOR SETTING CELLS BORDERS
623
    */
623
    */
624
    
624
    
625
    /**
625
    /**
626
    * Sets the width for the bottom border of the cell
626
    * Sets the width for the bottom border of the cell
627
    *
627
    *
628
    * @access public
628
    * @access public
629
    * @param integer $style style of the cell border. 1 => thin, 2 => thick.
629
    * @param integer $style style of the cell border. 1 => thin, 2 => thick.
630
    */
630
    */
631
    function setBottom($style)
631
    function setBottom($style)
632
    {
632
    {
633
        $this->_bottom = $style;
633
        $this->_bottom = $style;
634
    }
634
    }
635
    
635
    
636
    /**
636
    /**
637
    * Sets the width for the top border of the cell
637
    * Sets the width for the top border of the cell
638
    *
638
    *
639
    * @access public
639
    * @access public
640
    * @param integer $style style of the cell top border. 1 => thin, 2 => thick.
640
    * @param integer $style style of the cell top border. 1 => thin, 2 => thick.
641
    */
641
    */
642
    function setTop($style)
642
    function setTop($style)
643
    {
643
    {
644
        $this->_top = $style;
644
        $this->_top = $style;
645
    }
645
    }
646
    
646
    
647
    /**
647
    /**
648
    * Sets the width for the left border of the cell
648
    * Sets the width for the left border of the cell
649
    *
649
    *
650
    * @access public
650
    * @access public
651
    * @param integer $style style of the cell left border. 1 => thin, 2 => thick.
651
    * @param integer $style style of the cell left border. 1 => thin, 2 => thick.
652
    */
652
    */
653
    function setLeft($style)
653
    function setLeft($style)
654
    {
654
    {
655
        $this->_left = $style;
655
        $this->_left = $style;
656
    }
656
    }
657
    
657
    
658
    /**
658
    /**
659
    * Sets the width for the right border of the cell
659
    * Sets the width for the right border of the cell
660
    *
660
    *
661
    * @access public
661
    * @access public
662
    * @param integer $style style of the cell right border. 1 => thin, 2 => thick.
662
    * @param integer $style style of the cell right border. 1 => thin, 2 => thick.
663
    */
663
    */
664
    function setRight($style)
664
    function setRight($style)
665
    {
665
    {
666
        $this->_right = $style;
666
        $this->_right = $style;
667
    }
667
    }
668
    
668
    
669
    
669
    
670
    /**
670
    /**
671
    * Set cells borders to the same style
671
    * Set cells borders to the same style
672
    *
672
    *
673
    * @access public
673
    * @access public
674
    * @param integer $style style to apply for all cell borders. 1 => thin, 2 => thick.
674
    * @param integer $style style to apply for all cell borders. 1 => thin, 2 => thick.
675
    */
675
    */
676
    function setBorder($style)
676
    function setBorder($style)
677
    {
677
    {
678
        $this->setBottom($style);
678
        $this->setBottom($style);
679
        $this->setTop($style);
679
        $this->setTop($style);
680
        $this->setLeft($style);
680
        $this->setLeft($style);
681
        $this->setRight($style);
681
        $this->setRight($style);
682
    }
682
    }
683
    
683
    
684
    
684
    
685
    /*******************************************
685
    /*******************************************
686
    * FUNCTIONS FOR SETTING CELLS BORDERS COLORS
686
    * FUNCTIONS FOR SETTING CELLS BORDERS COLORS
687
    */
687
    */
688
    
688
    
689
    /**
689
    /**
690
    * Sets all the cell's borders to the same color
690
    * Sets all the cell's borders to the same color
691
    *
691
    *
692
    * @access public
692
    * @access public
693
    * @param mixed $color The color we are setting. Either a string (like 'blue'), 
693
    * @param mixed $color The color we are setting. Either a string (like 'blue'), 
694
    *                     or an integer (range is [8...63]).
694
    *                     or an integer (range is [8...63]).
695
    */
695
    */
696
    function setBorderColor($color)
696
    function setBorderColor($color)
697
    {
697
    {
698
        $this->setBottomColor($color);
698
        $this->setBottomColor($color);
699
        $this->setTopColor($color);
699
        $this->setTopColor($color);
700
        $this->setLeftColor($color);
700
        $this->setLeftColor($color);
701
        $this->setRightColor($color);
701
        $this->setRightColor($color);
702
    }
702
    }
703
    
703
    
704
    /**
704
    /**
705
    * Sets the cell's bottom border color
705
    * Sets the cell's bottom border color
706
    *
706
    *
707
    * @access public
707
    * @access public
708
    * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]).
708
    * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]).
709
    */
709
    */
710
    function setBottomColor($color)
710
    function setBottomColor($color)
711
    {
711
    {
712
        $value = $this->_getColor($color);
712
        $value = $this->_getColor($color);
713
        $this->_bottom_color = $value;
713
        $this->_bottom_color = $value;
714
    }
714
    }
715
    
715
    
716
    /**
716
    /**
717
    * Sets the cell's top border color
717
    * Sets the cell's top border color
718
    *
718
    *
719
    * @access public
719
    * @access public
720
    * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]).
720
    * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]).
721
    */
721
    */
722
    function setTopColor($color)
722
    function setTopColor($color)
723
    {
723
    {
724
        $value = $this->_getColor($color);
724
        $value = $this->_getColor($color);
725
        $this->_top_color = $value;
725
        $this->_top_color = $value;
726
    }
726
    }
727
    
727
    
728
    /**
728
    /**
729
    * Sets the cell's left border color
729
    * Sets the cell's left border color
730
    *
730
    *
731
    * @access public
731
    * @access public
732
    * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]).
732
    * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]).
733
    */
733
    */
734
    function setLeftColor($color)
734
    function setLeftColor($color)
735
    {
735
    {
736
        $value = $this->_getColor($color);
736
        $value = $this->_getColor($color);
737
        $this->_left_color = $value;
737
        $this->_left_color = $value;
738
    }
738
    }
739
    
739
    
740
    /**
740
    /**
741
    * Sets the cell's right border color
741
    * Sets the cell's right border color
742
    *
742
    *
743
    * @access public
743
    * @access public
744
    * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]).
744
    * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]).
745
    */
745
    */
746
    function setRightColor($color)
746
    function setRightColor($color)
747
    {
747
    {
748
        $value = $this->_getColor($color);
748
        $value = $this->_getColor($color);
749
        $this->_right_color = $value;
749
        $this->_right_color = $value;
750
    }
750
    }
751
    
751
    
752
    
752
    
753
    /**
753
    /**
754
    * Sets the cell's foreground color
754
    * Sets the cell's foreground color
755
    *
755
    *
756
    * @access public
756
    * @access public
757
    * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]).
757
    * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]).
758
    */
758
    */
759
    function setFgColor($color)
759
    function setFgColor($color)
760
    {
760
    {
761
        $value = $this->_getColor($color);
761
        $value = $this->_getColor($color);
762
        $this->_fg_color = $value;
762
        $this->_fg_color = $value;
763
    }
763
    }
764
      
764
      
765
    /**
765
    /**
766
    * Sets the cell's background color
766
    * Sets the cell's background color
767
    *
767
    *
768
    * @access public
768
    * @access public
769
    * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]).
769
    * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]).
770
    */
770
    */
771
    function setBgColor($color)
771
    function setBgColor($color)
772
    {
772
    {
773
        $value = $this->_getColor($color);
773
        $value = $this->_getColor($color);
774
        $this->_bg_color = $value;
774
        $this->_bg_color = $value;
775
    }
775
    }
776
    
776
    
777
    /**
777
    /**
778
    * Sets the cell's color
778
    * Sets the cell's color
779
    *
779
    *
780
    * @access public
780
    * @access public
781
    * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]).
781
    * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]).
782
    */
782
    */
783
    function setColor($color)
783
    function setColor($color)
784
    {
784
    {
785
        $value = $this->_getColor($color);
785
        $value = $this->_getColor($color);
786
        $this->_color = $value;
786
        $this->_color = $value;
787
    }
787
    }
788
    
788
    
789
    /**
789
    /**
790
    * Sets the fill pattern attribute of a cell
790
    * Sets the fill pattern attribute of a cell
791
    *
791
    *
792
    * @access public
792
    * @access public
793
    * @param integer $arg Optional. Defaults to 1. Meaningful values are: 0-18,
793
    * @param integer $arg Optional. Defaults to 1. Meaningful values are: 0-18,
794
    *                     0 meaning no background.
794
    *                     0 meaning no background.
795
    */
795
    */
796
    function setPattern($arg = 1)
796
    function setPattern($arg = 1)
797
    {
797
    {
798
        $this->_pattern = $arg;
798
        $this->_pattern = $arg;
799
    }
799
    }
800
    
800
    
801
    /**
801
    /**
802
    * Sets the underline of the text
802
    * Sets the underline of the text
803
    *
803
    *
804
    * @access public
804
    * @access public
805
    * @param integer $underline The value for underline. Possible values are:
805
    * @param integer $underline The value for underline. Possible values are:
806
    *                          1 => underline, 2 => double underline.
806
    *                          1 => underline, 2 => double underline.
807
    */
807
    */
808
    function setUnderline($underline)
808
    function setUnderline($underline)
809
    {
809
    {
810
        $this->_underline = $underline;
810
        $this->_underline = $underline;
811
    }
811
    }
812
 
812
 
813
    /**
813
    /**
814
    * Sets the font style as italic
814
    * Sets the font style as italic
815
    *
815
    *
816
    * @access public
816
    * @access public
817
    */
817
    */
818
    function setItalic()
818
    function setItalic()
819
    {
819
    {
820
        $this->_italic = 1;
820
        $this->_italic = 1;
821
    }
821
    }
822
 
822
 
823
    /**
823
    /**
824
    * Sets the font size 
824
    * Sets the font size 
825
    *
825
    *
826
    * @access public
826
    * @access public
827
    * @param integer $size The font size (in pixels I think).
827
    * @param integer $size The font size (in pixels I think).
828
    */
828
    */
829
    function setSize($size)
829
    function setSize($size)
830
    {
830
    {
831
        $this->_size = $size;
831
        $this->_size = $size;
832
    }
832
    }
833
    
833
    
834
    /**
834
    /**
835
    * Sets text wrapping
835
    * Sets text wrapping
836
    *
836
    *
837
    * @access public
837
    * @access public
838
    */
838
    */
839
    function setTextWrap()
839
    function setTextWrap()
840
    {
840
    {
841
        $this->_text_wrap = 1;
841
        $this->_text_wrap = 1;
842
    }
842
    }
843
 
843
 
844
    /**
844
    /**
845
    * Sets the orientation of the text
845
    * Sets the orientation of the text
846
    *
846
    *
847
    * @access public
847
    * @access public
848
    * @param integer $angle The rotation angle for the text (clockwise). Possible
848
    * @param integer $angle The rotation angle for the text (clockwise). Possible
849
                            values are: 0, 90, 270 and -1 for stacking top-to-bottom.
849
                            values are: 0, 90, 270 and -1 for stacking top-to-bottom.
850
    */
850
    */
851
    function setTextRotation($angle)
851
    function setTextRotation($angle)
852
    {
852
    {
853
        switch ($angle)
853
        switch ($angle)
854
        {
854
        {
855
            case 0:
855
            case 0:
856
                $this->_rotation = 0;
856
                $this->_rotation = 0;
857
                break;
857
                break;
858
            case 90:
858
            case 90:
859
                $this->_rotation = 3;
859
                $this->_rotation = 3;
860
                break;
860
                break;
861
            case 270:
861
            case 270:
862
                $this->_rotation = 2;
862
                $this->_rotation = 2;
863
                break;
863
                break;
864
            case -1:
864
            case -1:
865
                $this->_rotation = 1;
865
                $this->_rotation = 1;
866
                break;
866
                break;
867
            default :
867
            default :
868
                $this->raiseError("Invalid value for angle.".
868
                $this->raiseError("Invalid value for angle.".
869
                                  " Possible values are: 0, 90, 270 and -1 ".
869
                                  " Possible values are: 0, 90, 270 and -1 ".
870
                                  "for stacking top-to-bottom.");
870
                                  "for stacking top-to-bottom.");
871
                $this->_rotation = 0;
871
                $this->_rotation = 0;
872
                break;
872
                break;
873
        }
873
        }
874
    }
874
    }
875
 
875
 
876
    /**
876
    /**
877
    * Sets the numeric format.
877
    * Sets the numeric format.
878
    * It can be date, time, currency, etc...
878
    * It can be date, time, currency, etc...
879
    *
879
    *
880
    * @access public
880
    * @access public
881
    * @param integer $num_format The numeric format.
881
    * @param integer $num_format The numeric format.
882
    */
882
    */
883
    function setNumFormat($num_format)
883
    function setNumFormat($num_format)
884
    {
884
    {
885
        $this->_num_format = $num_format;
885
        $this->_num_format = $num_format;
886
    }
886
    }
887
 
887
 
888
    /**
888
    /**
889
    * Sets font as strikeout.
889
    * Sets font as strikeout.
890
    *
890
    *
891
    * @access public
891
    * @access public
892
    */
892
    */
893
    function setStrikeOut()
893
    function setStrikeOut()
894
    {
894
    {
895
        $this->_font_strikeout = 1;
895
        $this->_font_strikeout = 1;
896
    }
896
    }
897
 
897
 
898
    /**
898
    /**
899
    * Sets outlining for a font.
899
    * Sets outlining for a font.
900
    *
900
    *
901
    * @access public
901
    * @access public
902
    */
902
    */
903
    function setOutLine()
903
    function setOutLine()
904
    {
904
    {
905
        $this->_font_outline = 1;
905
        $this->_font_outline = 1;
906
    }
906
    }
907
 
907
 
908
    /**
908
    /**
909
    * Sets font as shadow.
909
    * Sets font as shadow.
910
    *
910
    *
911
    * @access public
911
    * @access public
912
    */
912
    */
913
    function setShadow()
913
    function setShadow()
914
    {
914
    {
915
        $this->_font_shadow = 1;
915
        $this->_font_shadow = 1;
916
    }
916
    }
917
 
917
 
918
    /**
918
    /**
919
    * Sets the script type of the text
919
    * Sets the script type of the text
920
    *
920
    *
921
    * @access public
921
    * @access public
922
    * @param integer $script The value for script type. Possible values are:
922
    * @param integer $script The value for script type. Possible values are:
923
    *                        1 => superscript, 2 => subscript.
923
    *                        1 => superscript, 2 => subscript.
924
    */
924
    */
925
    function setScript($script)
925
    function setScript($script)
926
    {
926
    {
927
        $this->_font_script = $script;
927
        $this->_font_script = $script;
928
    }
928
    }
929
 
929
 
930
    /**
930
    /**
931
    * Unlocks a cell. Useful for unprotecting particular cells of a protected sheet.
931
    * Unlocks a cell. Useful for unprotecting particular cells of a protected sheet.
932
    *
932
    *
933
    * @access public
933
    * @access public
934
    */
934
    */
935
    function setUnLocked()
935
    function setUnLocked()
936
    {
936
    {
937
        $this->_locked = 0;
937
        $this->_locked = 0;
938
    }
938
    }
939
}
939
}
940
?>
940
?>