previousFormat::setColor (Previous) (Next) Format::setUnderlinenext

View this page in Last updated: Sun, 18 Oct 2009
English | Brazilian Portuguese | Chinese | Dutch | French | German | Hungarian | Japanese | Polish | Russian | Spanish | Turkish

Format::setPattern

Format::setPattern – Sets the fill pattern attribute of a cell

Synopsis

require_once "Spreadsheet/Excel/Writer.php";

void Format::setPattern ( integer $arg=1 )

Description

Sets the fill pattern attribute of a cell. Use in combination with the setBgColor() and setFgColor() methods.

The example entitled "How background and foreground colors interact with patterns" is very helpful.

Parameter

  • integer $arg - Optional. Defaults to 1. Meaningful values are: 0-18. 0 = no background. 1 = solid "background" using the color set by setFgColor().

Note

This function can not be called statically.

Example

How background and foreground colors interact with patterns

<?php
require_once 'Spreadsheet/Excel/Writer.php';

$workbook = new Spreadsheet_Excel_Writer();
$worksheet =& $workbook->addWorksheet('testing colors and patterns');
$worksheet->setRow(130);
$worksheet->setRow(230);
$worksheet->setRow(330);

// valid patterns are 0 to 18
for ($i 0$i <= 18$i++)
{
    
// green in different patterns
    
$another_format1 =& $workbook->addFormat();
    
$another_format1->setBgColor('green');
    
$another_format1->setPattern($i);
    
$worksheet->write(1$i"pattern $i"$another_format1);

    
// red in different patterns
    
$another_format2 =& $workbook->addFormat();
    
$another_format2->setFgColor('red');
    
$another_format2->setPattern($i);
    
$worksheet->write(2$i"pattern $i"$another_format2);

    
// mixed red and green according to pattern
    
$another_format3 =& $workbook->addFormat();
    
$another_format3->setBgColor('green');
    
$another_format3->setFgColor('red');
    
$another_format3->setPattern($i);
    
$worksheet->write(3$i"pattern $i"$another_format3);
}

$workbook->send('setPattern.xls');
$workbook->close();
?>
previousFormat::setColor (Previous) (Next) Format::setUnderlinenext

Download Documentation Last updated: Sun, 18 Oct 2009
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
There are no user contributed notes for this page.