使用vb.net从Word文档中删除空表格单元格

时间:2017-06-21 09:07:25

标签: asp.net vb.net docx

我创建了一个带有Novacode docX的CV制作工具,它替换模板上的文本然后保存。我遇到的问题是我在表格中为格式化目的所做的就业历史。没有设定数量的就业历史记录,因此我必须为此创建最多10个记录模板。我的代码可以正常替换记录,但是我得到的空白表格单元格在文档末尾看起来不太好。有什么办法可以从生成的CV中删除这些空表单元格吗?

是否有可能为表格提供标题并找到该表格中的空单元格并将其删除?

我的代码 - 这是我从数据库表中获取数据后使用的替换文本代码

            'if there is data it replaces it as such
            document.ReplaceText("#employername1#", "NAME OF EMPLOYER")
            document.ReplaceText("#dates1#", "DATES OF EMPLOYMENT")
            document.ReplaceText("#position1#", "POSITION")
            document.ReplaceText("#reason1#", "REASON FOR LEAVING")
            document.ReplaceText("#jd1#", "JOB DESCRIPTION")
            document.ReplaceText("#skills1#", "ACHIEVEMENTS")


            document.ReplaceText("#empdata1#", employer)
            document.ReplaceText("#datedata1#", employmentsd & " to " & employmented)
            document.ReplaceText("#posdata1#", position)
            document.ReplaceText("#reasondata1#", reasonleave)
            document.ReplaceText("#jddata1#", jobdesc)
            document.ReplaceText("#skilldata1#", achievements)

        Else
            'if there is no data it replaces it with a blank(which is why i need to remove these blank cells)
            document.ReplaceText("#employername1#", "")
            document.ReplaceText("#dates1#", "")
            document.ReplaceText("#position1#", "")
            document.ReplaceText("#reason1#", "")
            document.ReplaceText("#jd1#", "")
            document.ReplaceText("#skills1#", "")

            document.ReplaceText("#empdata1#", "")
            document.ReplaceText("#datedata1#", "")
            document.ReplaceText("#posdata1#", "")
            document.ReplaceText("#reasondata1#", "")
            document.ReplaceText("#jddata1#", "")
            document.ReplaceText("#skilldata1#", "")

提前致谢。

0 个答案:

没有答案