Exemplo n.º 1
0
 /**
  * @dataProvider dataProviderForTestEscape
  *
  * @param string $stringToEscape
  * @param string $expectedEscapedString
  * @return void
  */
 public function testEscape($stringToEscape, $expectedEscapedString)
 {
     /** @noinspection PhpUnnecessaryFullyQualifiedNameInspection */
     $escaper = new \Box\Spout\Common\Escaper\XLSX();
     $escapedString = $escaper->escape($stringToEscape);
     $this->assertEquals($expectedEscapedString, $escapedString, 'Incorrect escaped string');
 }
Exemplo n.º 2
0
    /**
     * Creates the "workbook.xml" file under the "xl" folder
     *
     * @param Worksheet[] $worksheets
     * @return FileSystemHelper
     */
    public function createWorkbookFile($worksheets)
    {
        $workbookXmlFileContents = <<<EOD
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
    <sheets>

EOD;
        $escaper = new \Box\Spout\Common\Escaper\XLSX();
        /** @var Worksheet $worksheet */
        foreach ($worksheets as $worksheet) {
            $worksheetName = $worksheet->getExternalSheet()->getName();
            $worksheetId = $worksheet->getId();
            $workbookXmlFileContents .= '        <sheet name="' . $escaper->escape($worksheetName) . '" sheetId="' . $worksheetId . '" r:id="rIdSheet' . $worksheetId . '"/>' . PHP_EOL;
        }
        $workbookXmlFileContents .= <<<EOD
    </sheets>
</workbook>
EOD;
        $this->createFileWithContents($this->xlFolder, self::WORKBOOK_XML_FILE_NAME, $workbookXmlFileContents);
        return $this;
    }
Exemplo n.º 3
0
 /**
  * @dataProvider dataProviderForTestEscape
  *
  * @param string $stringToEscape
  * @param string $expectedEscapedString
  * @return void
  */
 public function testEscape($stringToEscape, $expectedEscapedString)
 {
     $escaper = new \Box\Spout\Common\Escaper\XLSX();
     $escapedString = $escaper->escape($stringToEscape);
     $this->assertEquals($expectedEscapedString, $escapedString, 'Incorrect escaped string');
 }