Exemplo n.º 1
0
function createWorkbook2($name, $dx, $dy)
{
    $wb = new java("org.apache.poi.hssf.usermodel.HSSFWorkbook");
    $sheet = $wb->createSheet("new sheet");
    $row = $sheet->createRow(0);
    //Aqua background
    $style = $wb->createCellStyle();
    $aqua = new java('org.apache.poi.hssf.util.HSSFColor$AQUA');
    $style->setFillBackgroundColor($aqua->index);
    $style->setFillPattern($style->BIG_SPOTS);
    $cell = $row->createCell(1);
    $cell->setCellValue("X");
    $cell->setCellStyle($style);
    //Orange "foreground", foreground being the fill foreground not the font color.
    $orange = new java('org.apache.poi.hssf.util.HSSFColor$ORANGE');
    $style->setFillForegroundColor($orange->index);
    $style->setFillPattern($style->SOLID_FOREGROUND);
    java_begin_document();
    for ($x = 0; $x < $dx; $x++) {
        $row = $sheet->createRow($x);
        for ($y = 0; $y < $dy; $y++) {
            $cell = $row->createCell($y);
            $cell->setCellValue("{$x} . {$y}");
            $cell->setCellStyle($style);
        }
    }
    java_end_document();
    // Write the output to a file
    $fileOut = new java("java.io.FileOutputStream", $name);
    $wb->write($fileOut);
    $fileOut->close();
}