Exemplo n.º 1
0
 public function testWriteData()
 {
     $cell = new Cell();
     $cell->setExportValue('Export');
     $row = new Row();
     $row->addCell($cell);
     $rows = new ArrayCollection();
     $rows->add($row);
     $export = new ExcelExport($this->factory);
     $export->setPhpExcel(new PHPExcel());
     $export->writeData($rows);
     $exportObject = $export->getPhpExcel();
     $this->assertEquals('Export', $exportObject->getActiveSheet()->getCell('A2')->getValue());
 }
Exemplo n.º 2
0
 public function testMapRows()
 {
     $column = new Column();
     $column->setProperty('name');
     $column->setCellType(new TextCell());
     $column->setLabel('User name');
     $columnCollection = new ArrayCollection();
     $columnCollection->add($column);
     $user = new User();
     $user->setId(1);
     $user->setName('some random name');
     $user->setEmail('*****@*****.**');
     $rowCollection = new ArrayCollection();
     $rowCollection->add($user);
     $mapper = new DatagridMapper();
     $actual = $mapper->mapRows($rowCollection, $columnCollection);
     $cell = new Cell();
     $cell->setProperty('name');
     $cell->setValue('some random name');
     $cell->setExportValue('some random name');
     $cell->setType('text');
     $cell->setView('text');
     $cell->setAttributes([]);
     $row = new Row();
     $row->setId(1);
     $row->setName(1);
     $row->setObject($user);
     $row->addCell($cell);
     $expected = new ArrayCollection();
     $expected->add($row);
     $this->assertEquals($actual, $expected);
 }
Exemplo n.º 3
0
 /**
  * Create a cell
  *
  * @param Column $column
  * @param object $row
  *
  * @return Cell
  */
 public function create(Column $column, $row)
 {
     $cellType = $column->getCellType();
     $cell = new Cell();
     $cell->setValue($cellType->getData($row, $column, $column->getCellAttributes()));
     $cell->setExportValue($cellType->getExportData($row, $column, $column->getCellAttributes()));
     $cell->setAttributes($column->getCellAttributes());
     $cell->setType($cellType->getName());
     $cell->setView($cellType->getView());
     $cell->setProperty($column->getProperty());
     return $cell;
 }