2017-03-04 97 views
0

我正在研究需要來自單詞模板的報告的項目。當沒有數據時,我需要刪除表頭和邊界。我嘗試了很多方法,但都在努力工作。刪除表格標題和Aspose word中的邊框.NET

我在像下面的模板:

Input

輸出是象下面這樣:

Output

我想刪除表的設計上點2

我的代碼像下面一樣

DataTable dtPersonalInfo = new dalCoro_Report().GetNonEffCertPersonalInfo(MemberID); 
     DataTable dtUnitAppt = new dalCoro_Report().GetNonEffCertExperienceUnitAppt(MemberID); 
     DataTable dtCourseInfo = new dalCoro_Report().GetNonEffCertExperienceCourse(MemberID); 
     DataTable dtMedalInfo = new dalCoro_Report().GetNonEffCertExperienceMedal(MemberID); 
     DataTable dtUnMissionInfo = new dalCoro_Report().GetNonEffCertUN_MSN(MemberID); 

     if (dtPersonalInfo.Rows.Count == 0) 
      return; 

     var fileName = "ExperienceCert_" + dtPersonalInfo.Rows[0]["PersonalNo"] + ".doc"; 
     var input = Server.MapPath(@"~\Coro_Report\Template\Certificates\6. Experience Cert2.doc"); 
     var output = Server.MapPath(@"~\Coro_Report\Report\" + fileName); 

     var doc = new Document(input); 


     dtPersonalInfo.TableName = "PersonalInfo"; 
     doc.MailMerge.ExecuteWithRegions(dtPersonalInfo); 

     if (dtUnitAppt.Rows.Count > 0) 
     { 
      doc.MailMerge.TrimWhitespaces = false; 

      dtUnitAppt.TableName = "UnitAppt"; 
      //doc.MailMerge.ExecuteWithRegions(dtUnitAppt); 
     } 

     if (dtCourseInfo.Rows.Count > 0) 
     { 
      doc.MailMerge.TrimWhitespaces = false; 

      dtCourseInfo.TableName = "Course"; 
      doc.MailMerge.ExecuteWithRegions(dtCourseInfo); 
     } 
     else 
     { 
      doc.MailMerge.RemoveEmptyRegions = true; 
     } 

     if (dtMedalInfo.Rows.Count > 0) 
     { 
      doc.MailMerge.TrimWhitespaces = false; 

      dtMedalInfo.TableName = "Medal"; 
      doc.MailMerge.ExecuteWithRegions(dtMedalInfo); 
     } 

     if (dtUnMissionInfo.Rows.Count > 0) 
     { 
      doc.MailMerge.TrimWhitespaces = false; 
      dtUnMissionInfo.TableName = "UnMission"; 
      doc.MailMerge.ExecuteWithRegions(dtUnMissionInfo); 
     } 


     doc.MailMerge.CleanupOptions = MailMergeCleanupOptions.RemoveUnusedRegions | MailMergeCleanupOptions.RemoveUnusedFields | MailMergeCleanupOptions.RemoveContainingFields | MailMergeCleanupOptions.RemoveEmptyParagraphs; 

     doc.MailMerge.DeleteFields(); 

     //Save the document 
     doc.Save(output); 

     ViewReport(fileName); 
+0

它看起來就像你不能在這個論壇上附加文件。我們需要在我們的最後測試這種情況。因此,請在[Aspose.Words論壇](https://www.aspose.com/community/forums/aspose.words-product-family/75/showforum.aspx)中創建一個新帖子。請壓縮並附上您的1)輸入Word文件,2)Aspose.Words生成輸出Word文檔,3)您的預期Word文檔和簡化的控制檯應用程序(源代碼無編譯錯誤)在您的線程中進行測試。我們會調查我們的情況,併爲您提供更多信息。我以開發者傳播者的身份與Aspose合作。 –

回答