Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ####gridExcelGenerator.php
- private function rowsParse($rows) {
- $i = 0;
- foreach ($rows as $row) {
- $rowArr = Array();
- $cellColors = Array();
- $cells = $row->cell;
- $k = 0;
- foreach ($cells as $cell) {
- if (isset($this->hiddenCols[$k])) {
- $k++;
- continue;
- }
- $cell_p = Array();
- if (isset($this->coll_options[$k][trim((string) $cell)]))
- $cell_p['text'] = $this->strip($this->coll_options[$k][trim((string) $cell)]);
- else
- $cell_p['text'] = $this->strip(trim((string) $cell));
- if (isset($cell->attributes()->bgColor)) {
- $cell_p['bg'] = (string) $cell->attributes()->bgColor;
- } else {
- $color = ($i%2 == 0) ? $this->scaleOneColor : $this->scaleTwoColor;
- $cell_p['bg'] = $color;
- }
- if (isset($cell->attributes()->textColor)) {
- $cell_p['textColor'] = (string) $cell->attributes()->textColor;
- } else {
- $cell_p['textColor'] = $this->textColor;
- }
- ### mod ###
- if (isset($row->attributes()->level)){
- $cell_p['indent'] = $row->attributes()->level;
- }
- ### end mod ###
- $cell_p['bold'] = (isset($cell->attributes()->bold) && $cell->attributes()->bold == 'bold') ? true : false;
- $cell_p['italic'] = (isset($cell->attributes()->italic) && $cell->attributes()->italic == 'italic') ? true : false;
- $cell_p['align'] = isset($cell->attributes()->align) ? $cell->attributes()->align : false;
- $rowArr[] = $cell_p;
- $k++;
- }
- $this->rows[] = $rowArr;
- $i++;
- }
- }
- ####gridExcelWrapper.php
- public function rowPrint($row, $rowHeight, $lineColor, $gridFontSize, $fontFamily) {
- $this->excel->getActiveSheet()->getRowDimension($this->currentRow)->setRowHeight($rowHeight);
- $styleArray = array(
- 'borders' => array(
- 'allborders' => array(
- 'style' => PHPExcel_Style_Border::BORDER_THIN,
- 'color' => array('argb' => $this->processColor($lineColor)),
- ),
- ),
- 'fill' => array(
- 'type' => PHPExcel_Style_Fill::FILL_SOLID,
- 'rotation' => 90
- ),
- 'font' => array(
- 'bold' => false,
- 'name' => $fontFamily,
- 'size' => $gridFontSize,
- 'color'=> Array('rgb'=> $this->processColor($this->textColor))
- )
- );
- $this->excel->getActiveSheet()->getStyle(($this->getColName(0).$this->currentRow.':'.$this->getColName(count($row) - 1).$this->currentRow))->applyFromArray($styleArray);
- for ($i = 0; $i < count($row); $i++) {
- if ($i >= count($this->types)) continue;
- $this->excel->getActiveSheet()->getStyle(($this->getColName($i).$this->currentRow.':'.$this->getColName($i).$this->currentRow))->applyFromArray($styleArray);
- $styleArray['font']['bold'] = $row[$i]['bold'];
- $styleArray['font']['italic'] = $row[$i]['italic'];
- $this->excel->setActiveSheetIndex(0);
- $text = $row[$i]['text'];
- if ((isset($this->columns[0][$i]['type']))&&(($this->columns[0][$i]['type'] == 'ch')||($this->columns[0][$i]['type'] == 'ra'))) {
- if ($text == '1') {
- $text = 'Yes';
- } else {
- $text = 'No';
- }
- }
- switch (strtolower($this->types[$i])) {
- case 'string':
- case 'str':
- case 'txt':
- case 'edtxt':
- case 'rotxt':
- case 'ro':
- case 'co':
- case 'coro':
- $this->excel->getActiveSheet()->getCell($this->getColName($i).$this->currentRow)->setValueExplicit($text, PHPExcel_Cell_DataType::TYPE_STRING);
- break;
- case 'number':
- case 'num':
- case 'edn':
- case 'ron':
- $text = str_replace(",", ".", $text);
- $this->excel->getActiveSheet()->getCell($this->getColName($i).$this->currentRow)->setValueExplicit($text, PHPExcel_Cell_DataType::TYPE_NUMERIC);
- break;
- case 'boolean':
- case 'bool':
- $this->excel->getActiveSheet()->getCell($this->getColName($i).$this->currentRow)->setValueExplicit($text, PHPExcel_Cell_DataType::TYPE_BOOL);
- break;
- case 'formula':
- $this->excel->getActiveSheet()->getCell($this->getColName($i).$this->currentRow)->setValueExplicit($text, PHPExcel_Cell_DataType::TYPE_FORMULA);
- break;
- case 'date':
- $this->excel->getActiveSheet()->setCellValueByColumnAndRow($i, $this->currentRow, $text);
- $this->excel->getActiveSheet()->getStyle($this->getColName($i).$this->currentRow)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2);
- break;
- ### mod ###
- case 'tree':
- $this->excel->getActiveSheet()->setCellValueByColumnAndRow($i, $this->currentRow, $text);
- $this->excel->getActiveSheet()->getStyle($this->getColName($i).$this->currentRow)->getAlignment()->setIndent($row[$i]['indent']);
- break;
- ### end mod ###
- default:
- $this->excel->getActiveSheet()->setCellValueByColumnAndRow($i, $this->currentRow, $text);
- break;
- }
- $this->excel->getActiveSheet()->getStyle($this->getColName($i).$this->currentRow)->getFill()->getStartColor()->setRGB($this->getRGB($row[$i]['bg']));
- $this->excel->getActiveSheet()->getStyle($this->getColName($i).$this->currentRow)->getFont()->getColor()->setRGB($this->getRGB($row[$i]['textColor']));
- $this->excel->getActiveSheet()->getStyle($this->getColName($i).$this->currentRow)->getFont()->getColor()->setRGB($this->getRGB($row[$i]['textColor']));
- $align = $row[$i]['align'];
- if ($align == false) $align = $this->columns[0][$i]['align'];
- $this->excel->getActiveSheet()->getStyle($this->getColName($i).$this->currentRow)->getAlignment()->setHorizontal($align);
- $this->excel->getActiveSheet()->getStyle($this->getColName($i).$this->currentRow)->getAlignment()->setWrapText(true);
- }
- $this->currentRow++;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement