PEAR Manual
PrevNext

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

Parameter

Note

This function can not be called statically.

Example

Example 29-1. Using setPattern()

require_once 'Spreadsheet/Excel/Writer.php';

$workbook = new Spreadsheet_Excel_Writer('test.xls');
$worksheet =& $workbook->addWorksheet('testing colors and patterns');
$worksheet->setRow(1, 30);
$worksheet->setRow(2, 30);
$worksheet->setRow(3, 30);

// 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, "another pattern", $another_format1);
    
    // red in different patterns
    $another_format2 =& $workbook->addFormat();
    $another_format2->setFgColor('red');
    $another_format2->setPattern($i);
    $worksheet->write(1, $i, "another pattern", $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(1, $i, "another pattern", $another_format3);
}
$workbook->close();

PrevHomeNext
Format::setColorUpFormat::setUnderline