Browse Source

alignment attributes can be missing but they can't be empty

Nguyen Nguyen 10 years ago
parent
commit
6a5b28f75e
1 changed files with 6 additions and 0 deletions
  1. 6 0
      xmlStyle.go

+ 6 - 0
xmlStyle.go

@@ -865,6 +865,12 @@ func (alignment *xlsxAlignment) Equals(other xlsxAlignment) bool {
 }
 
 func (alignment *xlsxAlignment) Marshal() (result string, err error) {
+	if alignment.Horizontal == "" {
+		alignment.Horizontal = "general"
+	}
+	if alignment.Vertical == "" {
+		alignment.Vertical = "bottom"
+	}
 	result = fmt.Sprintf(`<alignment horizontal="%s" indent="%d" shrinkToFit="%b" textRotation="%d" vertical="%s" wrapText="%b"/>`, alignment.Horizontal, alignment.Indent, bool2Int(alignment.ShrinkToFit), alignment.TextRotation, alignment.Vertical, bool2Int(alignment.WrapText))
 	return
 }