コード例 #1
0
ファイル: ExcelExportTest.php プロジェクト: Opifer/CrudBundle
 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());
 }
コード例 #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);
 }
コード例 #3
0
ファイル: DatagridMapper.php プロジェクト: Opifer/CrudBundle
 /**
  * Map a single row
  *
  * @param  object $object  The object the row represents
  * @param  array  $columns The columns that should be added to the row
  *
  * @return Row
  */
 public function mapRow($object, $columns)
 {
     $row = new Row();
     $row->setObject($object);
     $row->setId($object->getId());
     $row->setName($object->getId());
     foreach ($columns as $column) {
         $cellFactory = new CellFactory();
         $cell = $cellFactory->create($column, $object);
         $row->addCell($cell);
     }
     return $row;
 }