|
10 | 10 | use PhpOffice\PhpSpreadsheet\Style\Style as CellStyle; |
11 | 11 | use PhpOffice\PhpSpreadsheet\Worksheet\ColumnDimension; |
12 | 12 | use PhpOffice\PhpSpreadsheet\Worksheet\RowDimension; |
| 13 | +use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; |
13 | 14 |
|
14 | 15 | class Style |
15 | 16 | { |
16 | 17 | public const CELL_STYLE_PREFIX = 'ce'; |
17 | 18 | public const COLUMN_STYLE_PREFIX = 'co'; |
18 | 19 | public const ROW_STYLE_PREFIX = 'ro'; |
| 20 | + public const TABLE_STYLE_PREFIX = 'ta'; |
19 | 21 |
|
20 | 22 | private $writer; |
21 | 23 |
|
@@ -221,6 +223,26 @@ public function writeRowStyles(RowDimension $rowDimension, int $sheetId): void |
221 | 223 | $this->writer->endElement(); // Close style:style |
222 | 224 | } |
223 | 225 |
|
| 226 | + public function writeTableStyle(Worksheet $worksheet, int $sheetId): void |
| 227 | + { |
| 228 | + $this->writer->startElement('style:style'); |
| 229 | + $this->writer->writeAttribute('style:family', 'table'); |
| 230 | + $this->writer->writeAttribute( |
| 231 | + 'style:name', |
| 232 | + sprintf('%s%d', self::TABLE_STYLE_PREFIX, $sheetId) |
| 233 | + ); |
| 234 | + |
| 235 | + $this->writer->startElement('style:table-properties'); |
| 236 | + |
| 237 | + $this->writer->writeAttribute( |
| 238 | + 'table:display', |
| 239 | + $worksheet->getSheetState() === Worksheet::SHEETSTATE_VISIBLE ? 'true' : 'false' |
| 240 | + ); |
| 241 | + |
| 242 | + $this->writer->endElement(); // Close style:table-properties |
| 243 | + $this->writer->endElement(); // Close style:style |
| 244 | + } |
| 245 | + |
224 | 246 | public function write(CellStyle $style): void |
225 | 247 | { |
226 | 248 | $this->writer->startElement('style:style'); |
|
0 commit comments