예제 #1
0
 /**
  * @test
  * @covers Plum\PlumExcel\ExcelWriter::setHeader()
  * @covers Plum\PlumExcel\ExcelWriter::prepare()
  */
 public function prepareWritesHeader()
 {
     $sheet = $this->getMockWorksheet();
     $sheet->shouldReceive('setCellValueByColumnAndRow')->with(0, 1, 'City')->once();
     $sheet->shouldReceive('setCellValueByColumnAndRow')->with(1, 1, 'Country')->once();
     $this->excel->shouldReceive('getActiveSheet')->andReturn($sheet);
     $this->writer->setHeader(['City', 'Country']);
     $this->writer->prepare();
 }
예제 #2
0
<?php

/**
 * This file is part of plumphp/plum-excel.
 *
 * (c) Florian Eckerstorfer <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
require_once __DIR__ . '/../vendor/autoload.php';
use Plum\PlumExcel\ExcelWriter;
$writer = new ExcelWriter(__DIR__ . '/example.xlsx');
$writer->autoDetectHeader();
$writer->prepare();
$writer->writeItem(['Town' => 'Vienna', 'Country' => 'Austria', 'District' => 'Alsergrund', 'DistrictNumber' => 1090]);
$writer->writeItem(['Town' => 'Vienna', 'Country' => 'Austria', 'District' => 'Mariahilf', 'DistrictNumber' => 1060]);
$writer->finish();