@@ -523,6 +523,7 @@ class ExcelStyle {
523
523
private $ interior ;
524
524
private $ font ;
525
525
private $ border ;
526
+ private $ alignment ;
526
527
527
528
/**
528
529
* @param string $p_id The unique style id
@@ -611,6 +612,33 @@ function setBorder( $p_color, $p_line_style = 'Continuous', $p_weight = 1) {
611
612
}
612
613
}
613
614
615
+ /**
616
+ * Sets the aligment for the style
617
+ *
618
+ * @param int $p_wrap_text 1 to wrap, 0 to not wrap
619
+ * @param string $p_horizontal Automatic, Left, Center, Right, Fill, Justify, CenterAcrossSelection, Distributed, and JustifyDistributed
620
+ * @param string $p_vertical Automatic, Top, Bottom, Center, Justify, Distributed, and JustifyDistributed
621
+ */
622
+ function setAlignment ( $ p_wrap_text , $ p_horizontal = '' , $ p_vertical = '' ) {
623
+
624
+ if ( ! isset ( $ this ->alignment ) ) {
625
+ $ this ->alignment = new Alignment ();
626
+ }
627
+
628
+ if ( $ p_wrap_text != '' ) {
629
+ $ this ->alignment ->wrapText = $ p_wrap_text ;
630
+ }
631
+
632
+ if ( $ p_horizontal != '' ) {
633
+ $ this ->alignment ->horizontal = $ p_horizontal ;
634
+ }
635
+
636
+ if ( $ p_vertical != '' ) {
637
+ $ this ->alignment ->vertical = $ p_vertical ;
638
+ }
639
+
640
+ }
641
+
614
642
function asXml () {
615
643
616
644
$ xml = '<ss:Style ss:ID=" ' . $ this ->id .'" ss:Name=" ' .$ this ->id .'" ' ;
@@ -627,6 +655,9 @@ function asXml() {
627
655
if ( $ this ->border ) {
628
656
$ xml .= $ this ->border ->asXml ();
629
657
}
658
+ if ( $ this ->alignment ) {
659
+ $ xml .= $ this ->alignment ->asXml ();
660
+ }
630
661
$ xml .= '</ss:Style> ' ."\n" ;
631
662
632
663
return $ xml ;
@@ -721,3 +752,31 @@ function asXml() {
721
752
return $ xml ;
722
753
}
723
754
}
755
+
756
+ class Alignment {
757
+
758
+ public $ wrapText ;
759
+ public $ horizontal ;
760
+ public $ vertical ;
761
+
762
+ function asXml () {
763
+
764
+ $ xml = '<ss:Alignment ' ;
765
+
766
+ if ( $ this ->wrapText ) {
767
+ $ xml .= 'ss:WrapText=" ' . $ this ->wrapText .'" ' ;
768
+ }
769
+
770
+ if ( $ this ->horizontal ) {
771
+ $ xml .= 'ss:Horizontal=" ' . $ this ->horizontal .'" ' ;
772
+ }
773
+
774
+ if ( $ this ->vertical ) {
775
+ $ xml .= 'ss:Vertical=" ' . $ this ->vertical .'" ' ;
776
+ }
777
+
778
+ $ xml .= '/> ' ;
779
+
780
+ return $ xml ;
781
+ }
782
+ }
0 commit comments