Example #1
0
 public function testHasStyles()
 {
     $styleCollection = new StyleCollection([new Fill(), new Font()]);
     $cell = new Cell();
     $this->assertFalse($cell->hasStyles());
     $cell->setStyles($styleCollection);
     $this->assertTrue($cell->hasStyles());
 }
Example #2
0
 private function createCell($value = null, StyleCollection $styles = null)
 {
     if (null === $value) {
         $cell = new EmptyCell();
     } else {
         $cell = new Cell($value);
     }
     if (null !== $styles) {
         $cell->setStyles($styles);
     }
     return $cell;
 }
Example #3
0
 /**
  * @Given /^I add a new Cell with the value "([^"]*)" with the styleCollection with index "([^"]*)" in the Sheet with index "([^"]*)" at the coordinates "([^"]*)"$/
  */
 public function iAddANewCell($value, $styleCollectionIndex, $sheetIndex, $coordinate)
 {
     $coordinate = explode(',', $coordinate);
     $coordinate = new Coordinate($coordinate[0], $coordinate[1]);
     if ('null' === $styleCollectionIndex) {
         $styleCollection = null;
     } elseif ('current' === $styleCollectionIndex) {
         $styleCollection = $this->getMainContext()->getSubcontext('style')->styleCollection[$this->getMainContext()->getSubcontext('style')->currentStyleCollection];
     } else {
         $styleCollection = $this->getMainContext()->getSubcontext('style')->styleCollection[$styleCollectionIndex];
     }
     if ('null' === $value) {
         $cell = new EmptyCell();
     } else {
         $cell = new Cell($value);
     }
     if (null !== $styleCollection) {
         $cell->setStyles($styleCollection);
     }
     $this->sheetCollection['current' === $sheetIndex ? $this->currentSheetIndex : $sheetIndex]->addCell($cell, $coordinate);
 }
Example #4
0
 /**
  * Create a new row from data, index and styles
  *
  * @param  array $data
  * @param  int   $index
  * @param  StyleCollection $styles
  */
 private function createNewRow(array $data, $index, StyleCollection $styles = null)
 {
     foreach ($data as $value) {
         if (null === $value) {
             $cell = new EmptyCell();
         } else {
             $cell = new Cell($value);
         }
         if (null !== $styles) {
             $cell->setStyles($styles);
         }
         $this->table[$index][] = $cell;
     }
 }