Re: Spreadsheet_Excel_Writer color problem

From: Date: Wed, 07 Apr 2004 08:25:24 +0000
Subject: Re: Spreadsheet_Excel_Writer color problem
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-11686@lists.php.net to get a copy of this message
Matt Matijevich wrote:
I am using Spreadsheet_Excel_Writer version 0.7 to generate a small workseet and almost everything is working great. The only problem I have had so far is setting the color of a cell. If I try to use an integer to set the cell's color, it is alway black. If I use something like 'red' or 'green' to set a cells color, it works great. Has anyone else had any problems like this? Hi Matt,
I had the same problem, but I found it could be bypassed using SetCustomColor method. Besides, I don't remember where I saw it in the docs, but I think it was also required to use the setPattern method before applying colors. For example:
      // create xls book
      require_once 'Spreadsheet/Excel/Writer.php';
      $libro_xls = new Spreadsheet_Excel_Writer();
            // custom colors
      $libro_xls->setCustomColor(25, 255, 255, 255);      // white
      $libro_xls->setCustomColor(30, 24, 65, 90);      // dark blue
           // define title format
      $formato_titulo =& $libro_xls->addFormat();
      $formato_titulo->setBold();
      $formato_titulo->setColor(25);
      $formato_titulo->setPattern(1);
      $formato_titulo->setFgColor(30);
      $formato_titulo->setSize(24);
      $formato_titulo->setAlign('merge');
      // write the title
      $num_fila = 0;
      $hoja_xls->setRow($num_fila, 35);
      $hoja_xls->write($num_fila, 0, "TITLE", $formato_titulo);
      $hoja_xls->write($num_fila, 1, "", $formato_titulo);
      $hoja_xls->write($num_fila, 2, "", $formato_titulo);
      $libro_xls->send('test.xls');
   Hope that helps...
-- ===================================== Daniel García http://www.quintopino.com =====================================

« previous php.pear.general (#11686) next »