function _load(TikiSheet &$sheet) { $d = $this->data; foreach ($d->metadata->widths as $c => $width) { } foreach ($d->rows as $r => $row) { foreach ($row->columns as $c => $column) { $sheet->initCell($r, $c); //if cell has formula, use it, otherwise, use value, if value if blank, use '' if (!empty($column->formula)) { $sheet->setCalculation($column->formula); } else { $sheet->setValue(isset($column->value) ? $column->value : ''); } //Make cell able to span multi columns and rows $rowSpan = 1; $colSpan = 1; if (isset($column->rowspan)) { $rowSpan = $column->rowspan; } if (isset($column->colspan)) { $colSpan = $column->colspan; } $sheet->setRowSpan($rowSpan); $sheet->setColSpan($colSpan); $sheet->setDeadCells(); //setup cell css style if (!empty($column->style)) { $sheet->setStyle($column->style); } //setup cell html class if (isset($column->class)) { $sheet->setClass($column->class); } } } return true; }
function _load(TikiSheet &$sheet) { $d = $this->data; $rows = (int) $d->metadata->rows; $cols = (int) $d->metadata->columns; for ($r = 0; $r < $rows; $r++) { for ($c = 0; $c < $cols; $c++) { $ri = 'r' . $r; $ci = 'c' . $c; if (isset($d->data->{$ri}->{$ci}->value)) { $val = $d->data->{$ri}->{$ci}->value; } else { $val = ''; } $sheet->initCell($r, $c); if (isset($d->data->{$ri}->{$ci}->width) || isset($d->data->{$ri}->{$ci}->height)) { $sheet->setSize(isset($d->data->{$ri}->{$ci}->width) ? $d->data->{$ri}->{$ci}->width : 1, isset($d->data->{$ri}->{$ci}->height) ? $d->data->{$ri}->{$ci}->height : 1); } else { $sheet->setSize(1, 1); } $sheet->setValue($val); if (isset($d->data->{$ri}->{$ci}->formula)) { $formula = substr($d->data->{$ri}->{$ci}->formula, 1, strlen($d->data->{$ri}->{$ci}->formula) - 1); if (!empty($formula)) { $sheet->setCalculation($formula); } } if (isset($d->data->{$ri}->{$ci}->stl)) { $style = $d->data->{$ri}->{$ci}->stl; if (!empty($style)) { $sheet->setStyle($style); } } if (isset($d->data->{$ri}->{$ci}->cl)) { $class = $d->data->{$ri}->{$ci}->cl; if (!empty($class)) { $sheet->setClass($class); } } } } return true; }