🎨 Refactored XML generation logic and fixed content type override issues
This commit is contained in:
@@ -130,7 +130,19 @@ func (b *Body) ToXML() string {
|
||||
}
|
||||
|
||||
// 添加节属性
|
||||
xml += "<w:sectPr>"
|
||||
xml += "<w:sectPr xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\">"
|
||||
|
||||
// 页眉引用
|
||||
for _, headerRef := range b.SectionProperties.HeaderReference {
|
||||
xml += fmt.Sprintf("<w:headerReference w:type=\"%s\" r:id=\"%s\" />",
|
||||
headerRef.Type, headerRef.ID)
|
||||
}
|
||||
|
||||
// 页脚引用
|
||||
for _, footerRef := range b.SectionProperties.FooterReference {
|
||||
xml += fmt.Sprintf("<w:footerReference w:type=\"%s\" r:id=\"%s\" />",
|
||||
footerRef.Type, footerRef.ID)
|
||||
}
|
||||
|
||||
// 页面大小
|
||||
if b.SectionProperties.PageSize != nil {
|
||||
@@ -165,18 +177,6 @@ func (b *Body) ToXML() string {
|
||||
b.SectionProperties.DocGrid.LinePitch)
|
||||
}
|
||||
|
||||
// 页眉引用
|
||||
for _, headerRef := range b.SectionProperties.HeaderReference {
|
||||
xml += fmt.Sprintf("<w:headerReference w:type=\"%s\" r:id=\"%s\" />",
|
||||
headerRef.Type, headerRef.ID)
|
||||
}
|
||||
|
||||
// 页脚引用
|
||||
for _, footerRef := range b.SectionProperties.FooterReference {
|
||||
xml += fmt.Sprintf("<w:footerReference w:type=\"%s\" r:id=\"%s\" />",
|
||||
footerRef.Type, footerRef.ID)
|
||||
}
|
||||
|
||||
xml += "</w:sectPr>"
|
||||
|
||||
xml += "</w:body>"
|
||||
|
Reference in New Issue
Block a user