diff --git a/src/Spout/Writer/AbstractWriter.php b/src/Spout/Writer/AbstractWriter.php
old mode 100644
new mode 100755
diff --git a/src/Spout/Writer/Style/Style.php b/src/Spout/Writer/Style/Style.php
old mode 100644
new mode 100755
index a4254d7..594adde
--- a/src/Spout/Writer/Style/Style.php
+++ b/src/Spout/Writer/Style/Style.php
@@ -56,6 +56,15 @@ class Style
/** @var bool Whether specific font properties should be applied */
protected $shouldApplyFont = false;
+ protected $verticalAlignment = 'center';
+ protected $horizontalAlignment = 'center';
+
+ protected $hasVerticalAlignment = false;
+ protected $hasHorizontalAlignment = false;
+
+ protected $shouldApplyVerticalAlignment = false;
+ protected $shouldApplyHorizontalAlignment = false;
+
/** @var bool Whether the text should wrap in the cell (useful for long or multi-lines text) */
protected $shouldWrapText = false;
/** @var bool Whether the wrap text property was set */
@@ -278,6 +287,34 @@ class Style
return $this->numberFormat;
}
+ public function setVerticalAlignment($alignment) {
+ $this->verticalAlignment = $alignment;
+ $this->hasVerticalAlignment = true;
+ $this->shouldApplyVerticalAlignment = true;
+ }
+
+ public function setHorizontalAlignment($alignment) {
+ $this->horizontalAlignment = $alignment;
+ $this->hasHorizontalAlignment = true;
+ $this->shouldApplyHorizontalAlignment = true;
+ }
+
+ public function getVerticalAlignment() {
+ return $this->verticalAlignment;
+ }
+
+ public function getHorizontalAlignment() {
+ return $this->horizontalAlignment;
+ }
+
+ public function shouldApplyVerticalAlignment() {
+ return $this->shouldApplyVerticalAlignment;
+ }
+
+ public function shouldApplyHorizontalAlignment() {
+ return $this->shouldApplyHorizontalAlignment;
+ }
+
/**
* Serializes the style for future comparison with other styles.
diff --git a/src/Spout/Writer/Style/StyleBuilder.php b/src/Spout/Writer/Style/StyleBuilder.php
old mode 100644
new mode 100755
index 8521a1c..f97009f
--- a/src/Spout/Writer/Style/StyleBuilder.php
+++ b/src/Spout/Writer/Style/StyleBuilder.php
@@ -127,6 +127,16 @@ class StyleBuilder
return $this;
}
+ public function setVerticalAlignment($alignment) {
+ $this->style->setVerticalAlignment($alignment);
+ return $this;
+ }
+
+ public function setHorizontalAlignment($alignment) {
+ $this->style->setHorizontalAlignment($alignment);
+ return $this;
+ }
+
/**
* Returns the configured style. The style is cached and can be reused.
*
diff --git a/src/Spout/Writer/XLSX/Helper/StyleHelper.php b/src/Spout/Writer/XLSX/Helper/StyleHelper.php
old mode 100644
new mode 100755
index 789c72a..c95b27a
--- a/src/Spout/Writer/XLSX/Helper/StyleHelper.php
+++ b/src/Spout/Writer/XLSX/Helper/StyleHelper.php
@@ -175,10 +175,19 @@ EOD;
$content .= ' applyFont="1"';
}
- if ($style->shouldWrapText()) {
+ if ($style->shouldWrapText() || $style->shouldApplyVerticalAlignment() || $style->shouldApplyHorizontalAlignment()) {
$content .= ' applyAlignment="1">';
- $content .= '';
- $content .= '';
+ $content .= 'shouldWrapText()) {
+ $content .= 'wrapText="1" ';
+ }
+ if ($style->shouldApplyVerticalAlignment()) {
+ $content .= 'vertical="' . $style->getVerticalAlignment() . '" ';
+ }
+ if ($style->shouldApplyHorizontalAlignment()) {
+ $content .= 'horizontal="' . $style->getHorizontalAlignment() . '" ';
+ }
+ $content .= '/>';
} else {
$content .= '/>';
}