Add column width settings
This commit is contained in:
3 files changed
+87
-1
No files matched your search
@@ -92,6 +92,34 @@ class SheetTest extends TestCase
|
||||
$this->assertStringContainsString(' state="hidden"', $xmlContents, 'The sheet visibility should have been changed to "hidden"');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testSetSheetColumnWidthsShouldCreateSheetWidthCustomWidths()
|
||||
{
|
||||
$fileName = 'test_set_column_widths.xlsx';
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
$writer->openToFile($resourcePath);
|
||||
|
||||
$sheet = $writer->getCurrentSheet();
|
||||
$sheet->setColumnWidths([
|
||||
1 => 10,
|
||||
3 => 40,
|
||||
]);
|
||||
|
||||
$writer->addRow($this->createRowFromValues(['xlsx--11', 'xlsx--12']));
|
||||
$writer->close();
|
||||
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
$pathToWorkbookFile = $resourcePath . '#xl/worksheets/sheet1.xml';
|
||||
$xmlContents = file_get_contents('zip://' . $pathToWorkbookFile);
|
||||
|
||||
$this->assertStringContainsString('<cols>', $xmlContents);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $fileName
|
||||
* @param string $sheetName
|
||||
|
||||
Reference in new issue
Block a user