@@ -498,6 +498,7 @@ class ExcelStyle {
498
498
private $ interior ;
499
499
private $ font ;
500
500
private $ border ;
501
+ private $ alignment ;
501
502
502
503
/**
503
504
* @param string $p_id The unique style id
@@ -586,6 +587,33 @@ function setBorder( $p_color, $p_line_style = 'Continuous', $p_weight = 1) {
586
587
}
587
588
}
588
589
590
+ /**
591
+ * Sets the aligment for the style
592
+ *
593
+ * @param int $p_wrap_text 1 to wrap, 0 to not wrap
594
+ * @param string $p_horizontal Automatic, Left, Center, Right, Fill, Justify, CenterAcrossSelection, Distributed, and JustifyDistributed
595
+ * @param string $p_vertical Automatic, Top, Bottom, Center, Justify, Distributed, and JustifyDistributed
596
+ */
597
+ function setAlignment ( $ p_wrap_text , $ p_horizontal = '' , $ p_vertical = '' ) {
598
+
599
+ if ( ! isset ( $ this ->alignment ) ) {
600
+ $ this ->alignment = new Alignment ();
601
+ }
602
+
603
+ if ( $ p_wrap_text != '' ) {
604
+ $ this ->alignment ->wrapText = $ p_wrap_text ;
605
+ }
606
+
607
+ if ( $ p_horizontal != '' ) {
608
+ $ this ->alignment ->horizontal = $ p_horizontal ;
609
+ }
610
+
611
+ if ( $ p_vertical != '' ) {
612
+ $ this ->alignment ->vertical = $ p_vertical ;
613
+ }
614
+
615
+ }
616
+
589
617
function asXml () {
590
618
591
619
$ xml = '<ss:Style ss:ID=" ' . $ this ->id .'" ss:Name=" ' .$ this ->id .'" ' ;
@@ -602,6 +630,9 @@ function asXml() {
602
630
if ( $ this ->border ) {
603
631
$ xml .= $ this ->border ->asXml ();
604
632
}
633
+ if ( $ this ->alignment ) {
634
+ $ xml .= $ this ->alignment ->asXml ();
635
+ }
605
636
$ xml .= '</ss:Style> ' ."\n" ;
606
637
607
638
return $ xml ;
@@ -696,3 +727,31 @@ function asXml() {
696
727
return $ xml ;
697
728
}
698
729
}
730
+
731
+ class Alignment {
732
+
733
+ public $ wrapText ;
734
+ public $ horizontal ;
735
+ public $ vertical ;
736
+
737
+ function asXml () {
738
+
739
+ $ xml = '<ss:Alignment ' ;
740
+
741
+ if ( $ this ->wrapText ) {
742
+ $ xml .= 'ss:WrapText=" ' . $ this ->wrapText .'" ' ;
743
+ }
744
+
745
+ if ( $ this ->horizontal ) {
746
+ $ xml .= 'ss:Horizontal=" ' . $ this ->horizontal .'" ' ;
747
+ }
748
+
749
+ if ( $ this ->vertical ) {
750
+ $ xml .= 'ss:Vertical=" ' . $ this ->vertical .'" ' ;
751
+ }
752
+
753
+ $ xml .= '/> ' ;
754
+
755
+ return $ xml ;
756
+ }
757
+ }
0 commit comments