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