65 if (!defined(
'PHPEXCEL_ROOT')) {
69 define(
'PHPEXCEL_ROOT', dirname(__FILE__) .
'/../../../');
73 require_once PHPEXCEL_ROOT .
'PHPExcel/Style/Alignment.php';
76 require_once PHPEXCEL_ROOT .
'PHPExcel/Style/Border.php';
79 require_once PHPEXCEL_ROOT .
'PHPExcel/Style/Fill.php';
82 require_once PHPEXCEL_ROOT .
'PHPExcel/Style/Protection.php';
171 $this->_isStyleXf =
false;
172 $this->_BIFFVersion = 0x0600;
173 $this->_fontIndex = 0;
175 $this->_numberFormatIndex = 0;
177 $this->_text_justlast = 0;
179 $this->_fg_color = 0x40;
180 $this->_bg_color = 0x41;
184 $this->_bottom_color = 0x40;
185 $this->_top_color = 0x40;
186 $this->_left_color = 0x40;
187 $this->_right_color = 0x40;
188 $this->_diag_color = 0x40;
189 $this->_style = $style;
203 if ($this->_isStyleXf) {
206 $style = $this->
_mapLocked($this->_style->getProtection()->getLocked());
207 $style |= $this->
_mapHidden($this->_style->getProtection()->getHidden()) << 1;
211 $atr_num = ($this->_numberFormatIndex != 0)?1:0;
212 $atr_fnt = ($this->_fontIndex != 0)?1:0;
213 $atr_alc = ((int) $this->_style->getAlignment()->getWrapText())?1:0;
214 $atr_bdr = ($this->
_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) ||
215 $this->
_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) ||
216 $this->
_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) ||
217 $this->
_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()))?1:0;
218 $atr_pat = (($this->_fg_color != 0x40) ||
219 ($this->_bg_color != 0x41) ||
220 $this->
_mapFillType($this->_style->getFill()->getFillType()))?1:0;
221 $atr_prot = $this->
_mapLocked($this->_style->getProtection()->getLocked())
222 | $this->
_mapHidden($this->_style->getProtection()->getHidden());
225 if ($this->
_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) == 0) {
226 $this->_bottom_color = 0;
228 if ($this->
_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) == 0) {
229 $this->_top_color = 0;
231 if ($this->
_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) == 0) {
232 $this->_right_color = 0;
234 if ($this->
_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) == 0) {
235 $this->_left_color = 0;
237 if ($this->_diag == 0) {
238 $this->_diag_color = 0;
242 if ($this->_BIFFVersion == 0x0500) {
245 if ($this->_BIFFVersion == 0x0600) {
251 if ($this->_BIFFVersion == 0x0500) {
252 $align = $this->
_mapHAlign($this->_style->getAlignment()->getHorizontal());
253 $align |= (int) $this->_style->getAlignment()->getWrapText() << 3;
254 $align |= $this->
_mapVAlign($this->_style->getAlignment()->getVertical()) << 4;
255 $align |= $this->_text_justlast << 7;
257 $align |= $atr_num << 10;
258 $align |= $atr_fnt << 11;
259 $align |= $atr_alc << 12;
260 $align |= $atr_bdr << 13;
261 $align |= $atr_pat << 14;
262 $align |= $atr_prot << 15;
265 $icv |= $this->_bg_color << 7;
267 $fill = $this->
_mapFillType($this->_style->getFill()->getFillType());
268 $fill |= $this->
_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) << 6;
269 $fill |= $this->_bottom_color << 9;
271 $border1 = $this->
_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle());
272 $border1 |= $this->
_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) << 3;
273 $border1 |= $this->
_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) << 6;
274 $border1 |= $this->_top_color << 9;
277 $border2 |= $this->_right_color << 7;
279 $header = pack(
"vv", $record, $length);
280 $data = pack(
"vvvvvvvv", $ifnt, $ifmt, $style, $align,
283 }
elseif ($this->_BIFFVersion == 0x0600) {
284 $align = $this->
_mapHAlign($this->_style->getAlignment()->getHorizontal());
285 $align |= (int) $this->_style->getAlignment()->getWrapText() << 3;
286 $align |= $this->
_mapVAlign($this->_style->getAlignment()->getVertical()) << 4;
287 $align |= $this->_text_justlast << 7;
289 $used_attrib = $atr_num << 2;
290 $used_attrib |= $atr_fnt << 3;
291 $used_attrib |= $atr_alc << 4;
292 $used_attrib |= $atr_bdr << 5;
293 $used_attrib |= $atr_pat << 6;
294 $used_attrib |= $atr_prot << 7;
297 $icv |= $this->_bg_color << 7;
299 $border1 = $this->
_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle());
300 $border1 |= $this->
_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) << 4;
301 $border1 |= $this->
_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) << 8;
302 $border1 |= $this->
_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) << 12;
303 $border1 |= $this->_left_color << 16;
304 $border1 |= $this->_right_color << 23;
307 $border1 |= $diag_tl_to_rb << 30;
308 $border1 |= $diag_tr_to_lb << 31;
311 $border2 |= $this->_bottom_color << 7;
312 $border2 |= $this->_diag_color << 14;
313 $border2 |= $this->_diag << 21;
314 $border2 |= $this->
_mapFillType($this->_style->getFill()->getFillType()) << 26;
316 $header = pack(
"vv", $record, $length);
319 $biff8_options = $this->_style->getAlignment()->getIndent();
320 $biff8_options |= (int) $this->_style->getAlignment()->getShrinkToFit() << 4;
322 $data = pack(
"vvvC", $ifnt, $ifmt, $style, $align);
328 $data .= pack(
"VVv", $border1, $border2, $icv);
331 return($header .
$data);
341 $this->_BIFFVersion = $BIFFVersion;
351 $this->_isStyleXf = $value;
362 $this->_bottom_color = $colorIndex;
373 $this->_top_color = $colorIndex;
384 $this->_left_color = $colorIndex;
395 $this->_right_color = $colorIndex;
407 $this->_fg_color = $colorIndex;
418 $this->_bg_color = $colorIndex;
430 $this->_numberFormatIndex = $numberFormatIndex;
440 $this->_fontIndex = $value;
447 switch ($borderStyle) {
462 default:
return 0x00;
492 default:
return 0x00;
538 if ($textRotation >= 0) {
539 return $textRotation;
541 if ($textRotation == -165) {
544 if ($textRotation < 0) {
545 return 90 - $textRotation;