+require_once 'Pman.php';
class Pman_Core_SimpleExcel extends Pman
//$workbook = new Spreadsheet_Excel_Writer();
$workbook->setVersion(8);
// sending HTTP headers
-
+ $this->workbook = $workbook;
+
$formats = array();
$cfg['formats'] = isset($cfg['formats']) ? $cfg['formats'] : array();
}
-
- if (empty($cfg['workbooks'])) {
- $this->buildpage( $workbook, $formats , $data,$cfg);
- } else {
+
+ if (!empty($cfg['workbook'])) {
+ $this->buildPage( $formats , $data,$cfg);
+ } elseif (!empty($cfg['workbooks'])) {
foreach($cfg['workbooks'] as $i =>$wcfg) {
- $this->buildpage( $workbook, $formats , $data[$i],$wcfg);
+ $this->buildPage( $formats , $data[$i],$wcfg);
}
}
+ // if workbooks == false - > the user can call buildpage..
+
if (!empty($cfg['leave_open'])) {
- $this->workbook = $workbook;
$this->outfile2 = $outfile2;
return;
}
}
+
+
static function date($str)
{
}
- function buildpage($workbook, $formats , $data,$cfg)
+ function buildPage( $formats , $data, $cfg)
{
+ $workbook = $this->workbook;
//echo '<PRE>'; print_R($cfg);
// print_r($cfg);exit;
// Creating a worksheet
$this->worksheet_cfg[$cfg['workbook']] = &$cfg;
$this->formats = $formats;
-
+ //var_dump($cfg['workbook']);
+
$worksheet = $workbook->addWorksheet($cfg['workbook']);
if (is_a($worksheet, 'PEAR_Error')) {
die($worksheet->toString());
'header' => $col_cfg,
'dataIndex' => $col_cfg,
'width' => 50,
-
);
}
}
$format = isset($col_cfg['color']) ? $formats[$col_cfg['color']] : false;
$worksheet->write($start_row, $c, $col_cfg['header'],$format);
$worksheet->setColumn ( $c, $c, $col_cfg['width'] / 5);
-
}
$start_row++;
$this->start_row = &$start_row;
$hasRender = false;
- // DB_DataObject::debugLevel(1);
+
+
foreach($data as $r=>$clo) {
$hasRenderRow = $this->addLine($cfg['workbook'], $clo);
$hasRender = ($hasRender || $hasRenderRow) ? true : false;