35 require_once(
'PEAR.php');
254 $this->_xf_index = $index;
255 $this->_BIFF_version = $BIFF_version;
256 $this->font_index = 0;
257 $this->_font_name =
'Arial';
259 $this->_bold = 0x0190;
261 $this->_color = 0x7FFF;
262 $this->_underline = 0;
263 $this->_font_strikeout = 0;
264 $this->_font_outline = 0;
265 $this->_font_shadow = 0;
266 $this->_font_script = 0;
267 $this->_font_family = 0;
268 $this->_font_charset = 0;
270 $this->_num_format = 0;
275 $this->_text_h_align = 0;
276 $this->_text_wrap = 0;
277 $this->_text_v_align = 2;
278 $this->_text_justlast = 0;
279 $this->_rotation = 0;
281 $this->_fg_color = 0x40;
282 $this->_bg_color = 0x41;
292 $this->_bottom_color = 0x40;
293 $this->_top_color = 0x40;
294 $this->_left_color = 0x40;
295 $this->_right_color = 0x40;
296 $this->_diag_color = 0x40;
299 foreach($properties as $property => $value)
301 if(method_exists($this,
'set'.ucwords($property)))
303 $method_name =
'set'.ucwords($property);
304 $this->$method_name($value);
319 if ($style ==
"style") {
324 $style |= $this->_hidden << 1;
328 $atr_num = ($this->_num_format != 0)?1:0;
329 $atr_fnt = ($this->font_index != 0)?1:0;
331 $atr_bdr = ($this->_bottom ||
335 $atr_pat = (($this->_fg_color != 0x40) ||
336 ($this->_bg_color != 0x41) ||
341 if ($this->_bottom == 0) {
342 $this->_bottom_color = 0;
344 if ($this->_top == 0) {
345 $this->_top_color = 0;
347 if ($this->_right == 0) {
348 $this->_right_color = 0;
350 if ($this->_left == 0) {
351 $this->_left_color = 0;
353 if ($this->_diag == 0) {
354 $this->_diag_color = 0;
358 if ($this->_BIFF_version == 0x0500) {
361 if ($this->_BIFF_version == 0x0600) {
367 if ($this->_BIFF_version == 0x0500)
370 $align |= $this->_text_wrap << 3;
371 $align |= $this->_text_v_align << 4;
372 $align |= $this->_text_justlast << 7;
373 $align |= $this->_rotation << 8;
374 $align |= $atr_num << 10;
375 $align |= $atr_fnt << 11;
376 $align |= $atr_alc << 12;
377 $align |= $atr_bdr << 13;
378 $align |= $atr_pat << 14;
379 $align |= $atr_prot << 15;
382 $icv |= $this->_bg_color << 7;
385 $fill |= $this->_bottom << 6;
386 $fill |= $this->_bottom_color << 9;
389 $border1 |= $this->_left << 3;
390 $border1 |= $this->_right << 6;
391 $border1 |= $this->_top_color << 9;
394 $border2 |= $this->_right_color << 7;
396 $header = pack(
"vv", $record, $length);
397 $data = pack(
"vvvvvvvv", $ifnt, $ifmt, $style, $align,
401 elseif ($this->_BIFF_version == 0x0600)
404 $align |= $this->_text_wrap << 3;
405 $align |= $this->_text_v_align << 4;
406 $align |= $this->_text_justlast << 7;
408 $used_attrib = $atr_num << 2;
409 $used_attrib |= $atr_fnt << 3;
410 $used_attrib |= $atr_alc << 4;
411 $used_attrib |= $atr_bdr << 5;
412 $used_attrib |= $atr_pat << 6;
413 $used_attrib |= $atr_prot << 7;
416 $icv |= $this->_bg_color << 7;
419 $border1 |= $this->_right << 4;
420 $border1 |= $this->_top << 8;
421 $border1 |= $this->_bottom << 12;
422 $border1 |= $this->_left_color << 16;
423 $border1 |= $this->_right_color << 23;
426 $border1 |= $diag_tl_to_rb << 30;
427 $border1 |= $diag_tr_to_lb << 31;
430 $border2 |= $this->_bottom_color << 7;
431 $border2 |= $this->_diag_color << 14;
432 $border2 |= $this->_diag << 21;
433 $border2 |= $this->_pattern << 26;
435 $header = pack(
"vv", $record, $length);
438 $biff8_options = 0x00;
439 $data = pack(
"vvvC", $ifnt, $ifmt, $style, $align);
440 $data .= pack(
"CCC", $rotation, $biff8_options, $used_attrib);
441 $data .= pack(
"VVv", $border1, $border2, $icv);
444 return($header.$data);
454 $dyHeight = $this->_size * 20;
463 $cch = strlen($this->_font_name);
465 if ($this->_BIFF_version == 0x0500) {
466 $length = 0x0F + $cch;
468 elseif ($this->_BIFF_version == 0x0600) {
469 $length = 0x10 + $cch;
473 if ($this->_italic) {
476 if ($this->_font_strikeout) {
479 if ($this->_font_outline) {
482 if ($this->_font_shadow) {
486 $header = pack(
"vv", $record, $length);
487 if ($this->_BIFF_version == 0x0500) {
488 $data = pack(
"vvvvvCCCCC", $dyHeight, $grbit, $icv, $bls,
489 $sss, $uls, $bFamily,
490 $bCharSet, $reserved, $cch);
492 elseif ($this->_BIFF_version == 0x0600) {
493 $data = pack(
"vvvvvCCCCCC", $dyHeight, $grbit, $icv, $bls,
494 $sss, $uls, $bFamily,
495 $bCharSet, $reserved, $cch, $encoding);
497 return($header .
$data. $this->_font_name);
512 $key =
"$this->_font_name$this->_size";
513 $key .=
"$this->_font_script$this->_underline";
514 $key .=
"$this->_font_strikeout$this->_bold$this->_font_outline";
515 $key .=
"$this->_font_family$this->_font_charset";
516 $key .=
"$this->_font_shadow$this->_color$this->_italic";
517 $key = str_replace(
" ",
"_",$key);
528 return($this->_xf_index);
564 if($name_color ==
'') {
569 if(isset($colors[$name_color])) {
570 return($colors[$name_color]);
574 if(preg_match(
"/\D/",$name_color)) {
579 if($name_color < 8) {
580 return($name_color + 8);
584 if($name_color > 63) {
607 $this->_text_h_align = 1;
610 $this->_text_h_align = 2;
613 $this->_text_h_align = 2;
616 $this->_text_h_align = 3;
619 $this->_text_h_align = 4;
622 $this->_text_h_align = 5;
625 $this->_text_h_align = 6;
628 $this->_text_h_align = 7;
631 $this->_text_v_align = 0;
634 $this->_text_v_align = 1;
637 $this->_text_v_align = 1;
640 $this->_text_v_align = 2;
643 $this->_text_v_align = 3;
646 $this->_text_v_align = 4;
678 if($weight < 0x064) {
681 if($weight > 0x3E8) {
684 $this->_bold = $weight;
700 $this->_bottom = $style;
711 $this->_top = $style;
722 $this->_left = $style;
733 $this->_right = $style;
780 $this->_bottom_color = $value;
792 $this->_top_color = $value;
804 $this->_left_color = $value;
816 $this->_right_color = $value;
829 $this->_fg_color = $value;
830 if ($this->_pattern == 0) {
844 $this->_bg_color = $value;
845 if ($this->_pattern == 0) {
859 $this->_color = $value;
871 $this->_pattern = $arg;
883 $this->_underline = $underline;
904 $this->_size =
$size;
914 $this->_text_wrap = 1;
929 $this->_rotation = 0;
932 $this->_rotation = 3;
935 $this->_rotation = 2;
938 $this->_rotation = 1;
941 return $this->raiseError(
"Invalid value for angle.".
942 " Possible values are: 0, 90, 270 and -1 ".
943 "for stacking top-to-bottom.");
944 $this->_rotation = 0;
958 $this->_num_format = $num_format;
968 $this->_font_strikeout = 1;
978 $this->_font_outline = 1;
988 $this->_font_shadow = 1;
1000 $this->_font_script = $script;
1032 $this->_font_name = $font_family;