为有中文需求的客户提供多渠道中文技术支持.

Sat Mar 12, 2022 8:08 am

Code: Select all
       
        ZWordApplic = New Word.Application
        ZWordApplic.Visible = True
        ZDocument = ZWordApplic.Documents.Add()

        Dim tb1 As Word.Table = ZDocument.Tables.Add(ZWordApplic.Selection.Range, 10, 6)

        For i = 1 To 10
            For j = 1 To 6
                ' tb.Columns.Add(CStr(j))
                tb1.Rows(i).Cells(j).Range.InsertAfter(CStr(i) + "+" + CStr(j))
            Next
        Next

        ZDocument.SaveAs(Application.StartupPath + "\" + "gogo.docx")

        Dim section As Section = ZDocument.Sections(0)                                       ’‘’‘这里报错,                     其他信息: 值不在预期的范围内。
        Dim table As Table = TryCast(section.Tables(0), Table)
        table.ApplyHorizontalMerge(6, 2, 3)
        ZDocument.SaveToFile("gogo.docx")



不知道哪里出错,还是新建的文档里没有Sections。请高手指点。

excellency
 
Posts: 7
Joined: Sat Mar 12, 2022 7:58 am

Mon Mar 14, 2022 5:36 am

您好,

感谢您的咨询。
根据您提供的代码,我不太清楚您的代码逻辑,且您的代码看起来使用的不是我们的产品。如果您要使用我们的产品对word文件的表格进行编辑,请参考下面的代码:
Code: Select all
...
Dim document As Document = New Document()
document.LoadFromFile("gogo.docx")
Dim section As Section = document.Sections(0)
Dim table As Table = CType(section.Tables(0), Table)
table.ApplyHorizontalMerge(6, 2, 3)
document.SaveToFile("gogo.docx")

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Tue Mar 22, 2022 1:31 pm

多谢

excellency
 
Posts: 7
Joined: Sat Mar 12, 2022 7:58 am

Wed Mar 23, 2022 1:06 am

您好,

不客气!
以后您在使用我们产品时,如果遇到任何其他问题,请随时联系我们。

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Return to 中文技术支持

cron