Writer\Ods\Content: Fix CS
This commit is contained in:
parent
4efda2a512
commit
93b5337bda
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpSpreadsheet\Writer\Ods;
|
namespace PhpOffice\PhpSpreadsheet\Writer\Ods;
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* PhpSpreadsheet.
|
* PhpSpreadsheet.
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PhpSpreadsheet
|
* Copyright (c) 2006 - 2015 PhpSpreadsheet
|
||||||
|
@ -28,18 +28,19 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Ods;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use PhpOffice\PhpSpreadsheet\Cell;
|
use PhpOffice\PhpSpreadsheet\Cell;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
||||||
use PhpOffice\PhpSpreadsheet\Shared\XMLWriter;
|
use PhpOffice\PhpSpreadsheet\Shared\XMLWriter;
|
||||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
use PhpOffice\PhpSpreadsheet\Style\Fill;
|
use PhpOffice\PhpSpreadsheet\Style\Fill;
|
||||||
use PhpOffice\PhpSpreadsheet\Style\Font;
|
use PhpOffice\PhpSpreadsheet\Style\Font;
|
||||||
use PhpOffice\PhpSpreadsheet\Worksheet;
|
use PhpOffice\PhpSpreadsheet\Worksheet;
|
||||||
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
|
||||||
use PhpOffice\PhpSpreadsheet\Writer\Exception;
|
use PhpOffice\PhpSpreadsheet\Writer\Exception;
|
||||||
use PhpOffice\PhpSpreadsheet\Writer\Ods;
|
use PhpOffice\PhpSpreadsheet\Writer\Ods;
|
||||||
use PhpOffice\PhpSpreadsheet\Writer\Ods\Cell\Comment;
|
use PhpOffice\PhpSpreadsheet\Writer\Ods\Cell\Comment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @category PhpSpreadsheet
|
* @category PhpSpreadsheet
|
||||||
|
*
|
||||||
* @method Ods getParentWriter
|
* @method Ods getParentWriter
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2006 - 2015 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
|
* @copyright Copyright (c) 2006 - 2015 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||||
|
@ -200,7 +201,6 @@ class Content extends WriterPart
|
||||||
$prevColumn = -1;
|
$prevColumn = -1;
|
||||||
$cells = $row->getCellIterator();
|
$cells = $row->getCellIterator();
|
||||||
while ($cells->valid()) {
|
while ($cells->valid()) {
|
||||||
|
|
||||||
/** @var Cell $cell */
|
/** @var Cell $cell */
|
||||||
$cell = $cells->current();
|
$cell = $cells->current();
|
||||||
$column = Cell::columnIndexFromString($cell->getColumn()) - 1;
|
$column = Cell::columnIndexFromString($cell->getColumn()) - 1;
|
||||||
|
@ -288,7 +288,7 @@ class Content extends WriterPart
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write XF cell styles
|
* Write XF cell styles.
|
||||||
*
|
*
|
||||||
* @param XMLWriter $writer
|
* @param XMLWriter $writer
|
||||||
* @param Spreadsheet $spreadsheet
|
* @param Spreadsheet $spreadsheet
|
||||||
|
@ -296,7 +296,6 @@ class Content extends WriterPart
|
||||||
private function writeXfStyles(XMLWriter $writer, Spreadsheet $spreadsheet)
|
private function writeXfStyles(XMLWriter $writer, Spreadsheet $spreadsheet)
|
||||||
{
|
{
|
||||||
foreach ($spreadsheet->getCellXfCollection() as $style) {
|
foreach ($spreadsheet->getCellXfCollection() as $style) {
|
||||||
|
|
||||||
$writer->startElement('style:style');
|
$writer->startElement('style:style');
|
||||||
$writer->writeAttribute('style:name', self::CELL_STYLE_PREFIX . $style->getIndex());
|
$writer->writeAttribute('style:name', self::CELL_STYLE_PREFIX . $style->getIndex());
|
||||||
$writer->writeAttribute('style:family', 'table-cell');
|
$writer->writeAttribute('style:family', 'table-cell');
|
||||||
|
@ -334,17 +333,14 @@ class Content extends WriterPart
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($font->getUnderline() && $font->getUnderline() != Font::UNDERLINE_NONE) {
|
if ($font->getUnderline() && $font->getUnderline() != Font::UNDERLINE_NONE) {
|
||||||
|
|
||||||
$writer->writeAttribute('style:text-underline-style', 'solid');
|
$writer->writeAttribute('style:text-underline-style', 'solid');
|
||||||
$writer->writeAttribute('style:text-underline-width', 'auto');
|
$writer->writeAttribute('style:text-underline-width', 'auto');
|
||||||
$writer->writeAttribute('style:text-underline-color', 'font-color');
|
$writer->writeAttribute('style:text-underline-color', 'font-color');
|
||||||
|
|
||||||
switch ($font->getUnderline()) {
|
switch ($font->getUnderline()) {
|
||||||
|
|
||||||
case Font::UNDERLINE_DOUBLE:
|
case Font::UNDERLINE_DOUBLE:
|
||||||
$writer->writeAttribute('style:text-underline-type', 'double');
|
$writer->writeAttribute('style:text-underline-type', 'double');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Font::UNDERLINE_SINGLE:
|
case Font::UNDERLINE_SINGLE:
|
||||||
$writer->writeAttribute('style:text-underline-type', 'single');
|
$writer->writeAttribute('style:text-underline-type', 'single');
|
||||||
break;
|
break;
|
||||||
|
@ -363,18 +359,16 @@ class Content extends WriterPart
|
||||||
// Fill
|
// Fill
|
||||||
if ($fill = $style->getFill()) {
|
if ($fill = $style->getFill()) {
|
||||||
switch ($fill->getFillType()) {
|
switch ($fill->getFillType()) {
|
||||||
|
|
||||||
case Fill::FILL_SOLID:
|
case Fill::FILL_SOLID:
|
||||||
$writer->writeAttribute('fo:background-color', sprintf('#%s',
|
$writer->writeAttribute('fo:background-color', sprintf(
|
||||||
|
'#%s',
|
||||||
strtolower($fill->getStartColor()->getRGB())
|
strtolower($fill->getStartColor()->getRGB())
|
||||||
));
|
));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Fill::FILL_GRADIENT_LINEAR:
|
case Fill::FILL_GRADIENT_LINEAR:
|
||||||
case Fill::FILL_GRADIENT_PATH:
|
case Fill::FILL_GRADIENT_PATH:
|
||||||
/// TODO :: To be implemented
|
/// TODO :: To be implemented
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Fill::FILL_NONE:
|
case Fill::FILL_NONE:
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ use PhpOffice\PhpSpreadsheet\Style\Font;
|
||||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
use PhpOffice\PhpSpreadsheet\Writer\Ods;
|
use PhpOffice\PhpSpreadsheet\Writer\Ods;
|
||||||
use PhpOffice\PhpSpreadsheet\Writer\Ods\Content;
|
use PhpOffice\PhpSpreadsheet\Writer\Ods\Content;
|
||||||
use PhpOffice\PhpSpreadsheetTests\Worksheet\WorksheetColumnTest;
|
|
||||||
|
|
||||||
class ContentTest extends \PHPUnit_Framework_TestCase
|
class ContentTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
@ -24,7 +23,7 @@ class ContentTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
$xml = $content->write();
|
$xml = $content->write();
|
||||||
|
|
||||||
$this->assertXmlStringEqualsXmlFile($this->samplesPath . "/content-empty.xml", $xml);
|
$this->assertXmlStringEqualsXmlFile($this->samplesPath . '/content-empty.xml', $xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWriteSpreadsheet()
|
public function testWriteSpreadsheet()
|
||||||
|
@ -35,9 +34,9 @@ class ContentTest extends \PHPUnit_Framework_TestCase
|
||||||
$worksheet1 = $workbook->getActiveSheet();
|
$worksheet1 = $workbook->getActiveSheet();
|
||||||
$worksheet1->setCellValue('A1', 1); // Number
|
$worksheet1->setCellValue('A1', 1); // Number
|
||||||
$worksheet1->setCellValue('B1', 12345.6789); // Number
|
$worksheet1->setCellValue('B1', 12345.6789); // Number
|
||||||
$worksheet1->setCellValue('C1', "1"); // Number without cast
|
$worksheet1->setCellValue('C1', '1'); // Number without cast
|
||||||
$worksheet1->setCellValueExplicit('D1', "01234", DataType::TYPE_STRING); // Number casted to string
|
$worksheet1->setCellValueExplicit('D1', '01234', DataType::TYPE_STRING); // Number casted to string
|
||||||
$worksheet1->setCellValue('E1', "Lorem ipsum"); // String
|
$worksheet1->setCellValue('E1', 'Lorem ipsum'); // String
|
||||||
|
|
||||||
$worksheet1->setCellValue('A2', true); // Boolean
|
$worksheet1->setCellValue('A2', true); // Boolean
|
||||||
$worksheet1->setCellValue('B2', false); // Boolean
|
$worksheet1->setCellValue('B2', false); // Boolean
|
||||||
|
@ -51,7 +50,7 @@ class ContentTest extends \PHPUnit_Framework_TestCase
|
||||||
// Styles
|
// Styles
|
||||||
$worksheet1->getStyle('A1')->getFont()->setBold(true);
|
$worksheet1->getStyle('A1')->getFont()->setBold(true);
|
||||||
$worksheet1->getStyle('B1')->getFont()->setItalic(true);
|
$worksheet1->getStyle('B1')->getFont()->setItalic(true);
|
||||||
$worksheet1->getStyle('C1')->getFont()->setName("Courier");
|
$worksheet1->getStyle('C1')->getFont()->setName('Courier');
|
||||||
$worksheet1->getStyle('C1')->getFont()->setSize(14);
|
$worksheet1->getStyle('C1')->getFont()->setSize(14);
|
||||||
$worksheet1->getStyle('C1')->getFont()->setColor(new Color(Color::COLOR_BLUE));
|
$worksheet1->getStyle('C1')->getFont()->setColor(new Color(Color::COLOR_BLUE));
|
||||||
|
|
||||||
|
@ -73,6 +72,6 @@ class ContentTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
$xml = $content->write();
|
$xml = $content->write();
|
||||||
|
|
||||||
$this->assertXmlStringEqualsXmlFile($this->samplesPath . "/content-with-data.xml", $xml);
|
$this->assertXmlStringEqualsXmlFile($this->samplesPath . '/content-with-data.xml', $xml);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue