From e6483dc91e6a95d3ea91a9e1e22c4640f05fc8f8 Mon Sep 17 00:00:00 2001 From: tdx Date: Tue, 23 Dec 2025 03:08:46 +0000 Subject: [PATCH] SVN r1083 SVN-Revision: r1083 --- 插件库/Lskj.AutoCreatWord/CreateWordUtil.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/插件库/Lskj.AutoCreatWord/CreateWordUtil.cs b/插件库/Lskj.AutoCreatWord/CreateWordUtil.cs index 7aba195..2b29adb 100644 --- a/插件库/Lskj.AutoCreatWord/CreateWordUtil.cs +++ b/插件库/Lskj.AutoCreatWord/CreateWordUtil.cs @@ -71,9 +71,11 @@ namespace Lskj.AutoCreatWord bool hasMainTemp = false; try { + Section firstSection = null; if (!string.IsNullOrEmpty(mainTempPath) && File.Exists(mainTempPath)) { Section mainSection = new Section(document); + firstSection = mainSection; //mainSection.PageSetup.DifferentFirstPageHeaderFooter = false; document.Sections.Add(mainSection); hasMainTemp = true; @@ -183,13 +185,16 @@ namespace Lskj.AutoCreatWord document.LastSection.PageSetup.PageSize = section.PageSetup.PageSize; document.LastSection.PageSetup.Margins = section.PageSetup.Margins; } - Section mainSection = document.LastSection; + Section lastSection = document.LastSection; if (!moduleId.Equals("yw", StringComparison.OrdinalIgnoreCase)) { - //CpoyHeaderFooter(section, mainSection, HeaderFooterType.FooterEven); - //CpoyHeaderFooter(section, mainSection, HeaderFooterType.FooterOdd); - //CpoyHeaderFooter(section, mainSection, HeaderFooterType.HeaderEven); - //CpoyHeaderFooter(section, mainSection, HeaderFooterType.HeaderOdd); + if (firstSection != null) + { + CpoyHeaderFooter(firstSection, section, HeaderFooterType.FooterEven); + CpoyHeaderFooter(firstSection, section, HeaderFooterType.FooterOdd); + CpoyHeaderFooter(firstSection, section, HeaderFooterType.HeaderEven); + CpoyHeaderFooter(firstSection, section, HeaderFooterType.HeaderOdd); + } } bool isCopying = false; foreach (DocumentObject obj in section.Body.ChildObjects) @@ -207,7 +212,7 @@ namespace Lskj.AutoCreatWord { DocumentObject documentObject = obj.Clone(); //将内容添加到可替换模板 - mainSection.Body.ChildObjects.Add(documentObject); + lastSection.Body.ChildObjects.Add(documentObject); } } } @@ -1670,7 +1675,7 @@ namespace Lskj.AutoCreatWord HeaderFooter headerFooter = sourceSection.HeadersFooters[headerFooterType]; if (headerFooter != null && headerFooter.ChildObjects != null && headerFooter.ChildObjects.Count > 0) { - targetSection.HeadersFooters[headerFooterType].LinkToPrevious = false; + //targetSection.HeadersFooters[headerFooterType].LinkToPrevious = false; targetSection.HeadersFooters[headerFooterType].ChildObjects.Clear(); foreach (DocumentObject obj in headerFooter.ChildObjects) {