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();
}
Beispiel #2
0
java_end_document();
$t2 = java_values($Sys->currentTimeMillis());
$T4 = $t2 - $t1;
$Sys->gc();
$t1 = java_values($Sys->currentTimeMillis());
java_begin_document();
$v = new java("java.util.HashMap");
for ($i = 0; $i < $n; $i++) {
    $v->put($i, $i);
}
java_end_document();
$t2 = java_values($Sys->currentTimeMillis());
$T5 = $t2 - $t1;
$Sys->gc();
$t1 = java_values($Sys->currentTimeMillis());
java_begin_document();
$Array = new JavaClass("java.lang.reflect.Array");
$ar = $Array->newInstance(new JavaClass("java.lang.Integer"), $n);
for ($i = 0; $i < $n; $i++) {
    $Array->set($ar, $i, $i);
}
java_end_document();
$t2 = java_values($Sys->currentTimeMillis());
$T6 = $t2 - $t1;
$s = "";
for ($i = 0; $i < $n; $i++) {
    $s .= $i;
}
$Sys->gc();
$t1 = java_values($Sys->currentTimeMillis());
$str = new java("java.lang.String", $s);