getStyle(); if (!$style instanceof StyleTable && !$style instanceof StyleCell) { return ''; } $css = []; if (is_object($style) && method_exists($style, 'getLayout')) { if ($style->getLayout() == StyleTable::LAYOUT_FIXED) { $css['table-layout'] = 'fixed'; } elseif ($style->getLayout() == StyleTable::LAYOUT_AUTO) { $css['table-layout'] = 'auto'; } } if (is_object($style) && method_exists($style, 'isBidiVisual')) { if ($style->isBidiVisual()) { $css['direction'] = 'rtl'; } } foreach (['Top', 'Left', 'Bottom', 'Right'] as $direction) { $method = 'getBorder' . $direction . 'Style'; if (method_exists($style, $method)) { $outval = $style->{$method}(); if ($outval === 'single') { $outval = 'solid'; } if (is_string($outval) && 1 == preg_match('/^[a-z]+$/', $outval)) { $css['border-' . lcfirst($direction) . '-style'] = $outval; } } $method = 'getBorder' . $direction . 'Color'; if (method_exists($style, $method)) { $outval = $style->{$method}(); if (is_string($outval) && 1 == preg_match('/^[a-z]+$/', $outval)) { $css['border-' . lcfirst($direction) . '-color'] = $outval; } } $method = 'getBorder' . $direction . 'Size'; if (method_exists($style, $method)) { $outval = $style->{$method}(); if (is_numeric($outval)) { // size is in twips - divide by 20 to get points $css['border-' . lcfirst($direction) . '-width'] = ((string) ($outval / 20)) . 'pt'; } } } return $this->assembleCss($css); } }