| 1 |
<?php |
| 2 |
|
| 3 |
namespace TablePress\PhpOffice\PhpSpreadsheet\Worksheet\Table; |
| 4 |
|
| 5 |
use TablePress\PhpOffice\PhpSpreadsheet\Style\Style; |
| 6 |
use TablePress\PhpOffice\PhpSpreadsheet\Worksheet\Table; |
| 7 |
|
| 8 |
class TableStyle |
| 9 |
{ |
| 10 |
const TABLE_STYLE_NONE = ''; |
| 11 |
const TABLE_STYLE_LIGHT1 = 'TableStyleLight1'; |
| 12 |
const TABLE_STYLE_LIGHT2 = 'TableStyleLight2'; |
| 13 |
const TABLE_STYLE_LIGHT3 = 'TableStyleLight3'; |
| 14 |
const TABLE_STYLE_LIGHT4 = 'TableStyleLight4'; |
| 15 |
const TABLE_STYLE_LIGHT5 = 'TableStyleLight5'; |
| 16 |
const TABLE_STYLE_LIGHT6 = 'TableStyleLight6'; |
| 17 |
const TABLE_STYLE_LIGHT7 = 'TableStyleLight7'; |
| 18 |
const TABLE_STYLE_LIGHT8 = 'TableStyleLight8'; |
| 19 |
const TABLE_STYLE_LIGHT9 = 'TableStyleLight9'; |
| 20 |
const TABLE_STYLE_LIGHT10 = 'TableStyleLight10'; |
| 21 |
const TABLE_STYLE_LIGHT11 = 'TableStyleLight11'; |
| 22 |
const TABLE_STYLE_LIGHT12 = 'TableStyleLight12'; |
| 23 |
const TABLE_STYLE_LIGHT13 = 'TableStyleLight13'; |
| 24 |
const TABLE_STYLE_LIGHT14 = 'TableStyleLight14'; |
| 25 |
const TABLE_STYLE_LIGHT15 = 'TableStyleLight15'; |
| 26 |
const TABLE_STYLE_LIGHT16 = 'TableStyleLight16'; |
| 27 |
const TABLE_STYLE_LIGHT17 = 'TableStyleLight17'; |
| 28 |
const TABLE_STYLE_LIGHT18 = 'TableStyleLight18'; |
| 29 |
const TABLE_STYLE_LIGHT19 = 'TableStyleLight19'; |
| 30 |
const TABLE_STYLE_LIGHT20 = 'TableStyleLight20'; |
| 31 |
const TABLE_STYLE_LIGHT21 = 'TableStyleLight21'; |
| 32 |
const TABLE_STYLE_MEDIUM1 = 'TableStyleMedium1'; |
| 33 |
const TABLE_STYLE_MEDIUM2 = 'TableStyleMedium2'; |
| 34 |
const TABLE_STYLE_MEDIUM3 = 'TableStyleMedium3'; |
| 35 |
const TABLE_STYLE_MEDIUM4 = 'TableStyleMedium4'; |
| 36 |
const TABLE_STYLE_MEDIUM5 = 'TableStyleMedium5'; |
| 37 |
const TABLE_STYLE_MEDIUM6 = 'TableStyleMedium6'; |
| 38 |
const TABLE_STYLE_MEDIUM7 = 'TableStyleMedium7'; |
| 39 |
const TABLE_STYLE_MEDIUM8 = 'TableStyleMedium8'; |
| 40 |
const TABLE_STYLE_MEDIUM9 = 'TableStyleMedium9'; |
| 41 |
const TABLE_STYLE_MEDIUM10 = 'TableStyleMedium10'; |
| 42 |
const TABLE_STYLE_MEDIUM11 = 'TableStyleMedium11'; |
| 43 |
const TABLE_STYLE_MEDIUM12 = 'TableStyleMedium12'; |
| 44 |
const TABLE_STYLE_MEDIUM13 = 'TableStyleMedium13'; |
| 45 |
const TABLE_STYLE_MEDIUM14 = 'TableStyleMedium14'; |
| 46 |
const TABLE_STYLE_MEDIUM15 = 'TableStyleMedium15'; |
| 47 |
const TABLE_STYLE_MEDIUM16 = 'TableStyleMedium16'; |
| 48 |
const TABLE_STYLE_MEDIUM17 = 'TableStyleMedium17'; |
| 49 |
const TABLE_STYLE_MEDIUM18 = 'TableStyleMedium18'; |
| 50 |
const TABLE_STYLE_MEDIUM19 = 'TableStyleMedium19'; |
| 51 |
const TABLE_STYLE_MEDIUM20 = 'TableStyleMedium20'; |
| 52 |
const TABLE_STYLE_MEDIUM21 = 'TableStyleMedium21'; |
| 53 |
const TABLE_STYLE_MEDIUM22 = 'TableStyleMedium22'; |
| 54 |
const TABLE_STYLE_MEDIUM23 = 'TableStyleMedium23'; |
| 55 |
const TABLE_STYLE_MEDIUM24 = 'TableStyleMedium24'; |
| 56 |
const TABLE_STYLE_MEDIUM25 = 'TableStyleMedium25'; |
| 57 |
const TABLE_STYLE_MEDIUM26 = 'TableStyleMedium26'; |
| 58 |
const TABLE_STYLE_MEDIUM27 = 'TableStyleMedium27'; |
| 59 |
const TABLE_STYLE_MEDIUM28 = 'TableStyleMedium28'; |
| 60 |
const TABLE_STYLE_DARK1 = 'TableStyleDark1'; |
| 61 |
const TABLE_STYLE_DARK2 = 'TableStyleDark2'; |
| 62 |
const TABLE_STYLE_DARK3 = 'TableStyleDark3'; |
| 63 |
const TABLE_STYLE_DARK4 = 'TableStyleDark4'; |
| 64 |
const TABLE_STYLE_DARK5 = 'TableStyleDark5'; |
| 65 |
const TABLE_STYLE_DARK6 = 'TableStyleDark6'; |
| 66 |
const TABLE_STYLE_DARK7 = 'TableStyleDark7'; |
| 67 |
const TABLE_STYLE_DARK8 = 'TableStyleDark8'; |
| 68 |
const TABLE_STYLE_DARK9 = 'TableStyleDark9'; |
| 69 |
const TABLE_STYLE_DARK10 = 'TableStyleDark10'; |
| 70 |
const TABLE_STYLE_DARK11 = 'TableStyleDark11'; |
| 71 |
|
| 72 |
/** |
| 73 |
* Theme. |
| 74 |
*/ |
| 75 |
private string $theme; |
| 76 |
|
| 77 |
/** |
| 78 |
* Show First Column. |
| 79 |
*/ |
| 80 |
private bool $showFirstColumn = false; |
| 81 |
|
| 82 |
/** |
| 83 |
* Show Last Column. |
| 84 |
*/ |
| 85 |
private bool $showLastColumn = false; |
| 86 |
|
| 87 |
/** |
| 88 |
* Show Row Stripes. |
| 89 |
*/ |
| 90 |
private bool $showRowStripes = false; |
| 91 |
|
| 92 |
/** |
| 93 |
* Show Column Stripes. |
| 94 |
*/ |
| 95 |
private bool $showColumnStripes = false; |
| 96 |
|
| 97 |
/** |
| 98 |
* TableDxfsStyle. |
| 99 |
*/ |
| 100 |
private ?TableDxfsStyle $tableStyle = null; |
| 101 |
|
| 102 |
/** |
| 103 |
* Table. |
| 104 |
*/ |
| 105 |
private ?Table $table = null; |
| 106 |
|
| 107 |
/** |
| 108 |
* Create a new Table Style. |
| 109 |
* |
| 110 |
* @param string $theme (e.g. TableStyle::TABLE_STYLE_MEDIUM2) |
| 111 |
*/ |
| 112 |
public function __construct(string $theme = self::TABLE_STYLE_MEDIUM2) |
| 113 |
{ |
| 114 |
$this->theme = $theme; |
| 115 |
} |
| 116 |
|
| 117 |
/** |
| 118 |
* Get theme. |
| 119 |
*/ |
| 120 |
public function getTheme(): string |
| 121 |
{ |
| 122 |
return $this->theme; |
| 123 |
} |
| 124 |
|
| 125 |
/** |
| 126 |
* Set theme. |
| 127 |
*/ |
| 128 |
public function setTheme(string $theme): self |
| 129 |
{ |
| 130 |
$this->theme = $theme; |
| 131 |
|
| 132 |
return $this; |
| 133 |
} |
| 134 |
|
| 135 |
/** |
| 136 |
* Get show First Column. |
| 137 |
*/ |
| 138 |
public function getShowFirstColumn(): bool |
| 139 |
{ |
| 140 |
return $this->showFirstColumn; |
| 141 |
} |
| 142 |
|
| 143 |
/** |
| 144 |
* Set show First Column. |
| 145 |
*/ |
| 146 |
public function setShowFirstColumn(bool $showFirstColumn): self |
| 147 |
{ |
| 148 |
$this->showFirstColumn = $showFirstColumn; |
| 149 |
|
| 150 |
return $this; |
| 151 |
} |
| 152 |
|
| 153 |
/** |
| 154 |
* Get show Last Column. |
| 155 |
*/ |
| 156 |
public function getShowLastColumn(): bool |
| 157 |
{ |
| 158 |
return $this->showLastColumn; |
| 159 |
} |
| 160 |
|
| 161 |
/** |
| 162 |
* Set show Last Column. |
| 163 |
*/ |
| 164 |
public function setShowLastColumn(bool $showLastColumn): self |
| 165 |
{ |
| 166 |
$this->showLastColumn = $showLastColumn; |
| 167 |
|
| 168 |
return $this; |
| 169 |
} |
| 170 |
|
| 171 |
/** |
| 172 |
* Get show Row Stripes. |
| 173 |
*/ |
| 174 |
public function getShowRowStripes(): bool |
| 175 |
{ |
| 176 |
return $this->showRowStripes; |
| 177 |
} |
| 178 |
|
| 179 |
/** |
| 180 |
* Set show Row Stripes. |
| 181 |
*/ |
| 182 |
public function setShowRowStripes(bool $showRowStripes): self |
| 183 |
{ |
| 184 |
$this->showRowStripes = $showRowStripes; |
| 185 |
|
| 186 |
return $this; |
| 187 |
} |
| 188 |
|
| 189 |
/** |
| 190 |
* Get show Column Stripes. |
| 191 |
*/ |
| 192 |
public function getShowColumnStripes(): bool |
| 193 |
{ |
| 194 |
return $this->showColumnStripes; |
| 195 |
} |
| 196 |
|
| 197 |
/** |
| 198 |
* Set show Column Stripes. |
| 199 |
*/ |
| 200 |
public function setShowColumnStripes(bool $showColumnStripes): self |
| 201 |
{ |
| 202 |
$this->showColumnStripes = $showColumnStripes; |
| 203 |
|
| 204 |
return $this; |
| 205 |
} |
| 206 |
|
| 207 |
/** |
| 208 |
* Get this Style's Dxfs TableStyle. |
| 209 |
*/ |
| 210 |
public function getTableDxfsStyle(): ?TableDxfsStyle |
| 211 |
{ |
| 212 |
return $this->tableStyle; |
| 213 |
} |
| 214 |
|
| 215 |
/** |
| 216 |
* Set this Style's Dxfs TableStyle. |
| 217 |
* |
| 218 |
* @param Style[] $dxfs |
| 219 |
*/ |
| 220 |
public function setTableDxfsStyle(TableDxfsStyle $tableStyle, array $dxfs): self |
| 221 |
{ |
| 222 |
$this->tableStyle = $tableStyle; |
| 223 |
|
| 224 |
if ($this->tableStyle->getHeaderRow() !== null && isset($dxfs[$this->tableStyle->getHeaderRow()])) { |
| 225 |
$this->tableStyle->setHeaderRowStyle($dxfs[$this->tableStyle->getHeaderRow()]); |
| 226 |
} |
| 227 |
if ($this->tableStyle->getFirstRowStripe() !== null && isset($dxfs[$this->tableStyle->getFirstRowStripe()])) { |
| 228 |
$this->tableStyle->setFirstRowStripeStyle($dxfs[$this->tableStyle->getFirstRowStripe()]); |
| 229 |
} |
| 230 |
if ($this->tableStyle->getSecondRowStripe() !== null && isset($dxfs[$this->tableStyle->getSecondRowStripe()])) { |
| 231 |
$this->tableStyle->setSecondRowStripeStyle($dxfs[$this->tableStyle->getSecondRowStripe()]); |
| 232 |
} |
| 233 |
|
| 234 |
return $this; |
| 235 |
} |
| 236 |
|
| 237 |
/** |
| 238 |
* Get this Style's Table. |
| 239 |
*/ |
| 240 |
public function getTable(): ?Table |
| 241 |
{ |
| 242 |
return $this->table; |
| 243 |
} |
| 244 |
|
| 245 |
/** |
| 246 |
* Set this Style's Table. |
| 247 |
*/ |
| 248 |
public function setTable(?Table $table = null): self |
| 249 |
{ |
| 250 |
$this->table = $table; |
| 251 |
|
| 252 |
return $this; |
| 253 |
} |
| 254 |
} |
| 255 |
|