0

使用下面的代码,我最多可以添加 10 行。当我尝试添加更多行时,Aspose 抛出异常。

Try
    Dim doc As Document = New Document("C:\Users\reddy\Desktop\Junk\Out.doc")
    Dim table As Table = DirectCast(doc.GetChild(NodeType.Table, 0, True), Table)
    For i As Integer = 0 To 10
        Dim clonedRow As Row = DirectCast(table.LastRow.Clone(True), Row)
        For Each cell As Cell In clonedRow.Cells
            cell.CellFormat.Orientation = TextOrientation.Horizontal
            cell.CellFormat.WrapText = True
            cell.CellFormat.FitText = True
            cell.FirstParagraph.Runs.Clear()
            cell.FirstParagraph.AppendChild(New Aspose.Words.Run(doc, "hellotext"))
        Next
        ' Add the row to the end of the table.
        table.AppendChild(clonedRow)
    Next

    doc.Save("C:\Users\reddy\Desktop\Junk\Out1.pdf")

Catch x As Exception
    Dim y As String = ""
End Try

例外: [例外[1]

堆栈跟踪:

   at System.Collections.ArrayList.get_Item(Int32 index)
   at    .(    , Int32 , Boolean )
   at    .(ArrayList , Boolean )
   at    .(ArrayList , Int32 )
   at    .(ArrayList ,    , Int32 , Boolean , Boolean )
   at    . (Table )
   at    .(Table , Boolean )
   at    .(Table , Stack , Boolean )
   at    .VisitTableEnd(Table )
   at Aspose.Words.CompositeNode.AcceptCore(DocumentVisitor visitor)
   at Aspose.Words.CompositeNode.AcceptChildren(DocumentVisitor visitor)
   at Aspose.Words.CompositeNode.AcceptCore(DocumentVisitor visitor)
   at Aspose.Words.CompositeNode.AcceptChildren(DocumentVisitor visitor)
   at Aspose.Words.CompositeNode.AcceptCore(DocumentVisitor visitor)
   at Aspose.Words.CompositeNode.AcceptChildren(DocumentVisitor visitor)
   at Aspose.Words.CompositeNode.AcceptCore(DocumentVisitor visitor)
   at    .(    )
   at    .(Document , ​   )
   at    .(    ,     )
   at    .      (    )
   at    .      (    )
   at Aspose.Words.Document.(Stream , String , SaveOptions )
   at Aspose.Words.Document.Save(String fileName)
   at WindowsApplication1.IMPlanSetupTest.newpdfgen() in C:\Projects\BFL\Source\BFL.WindowsApplication1\IMPlanSetupTest.vb:line 63

我对这里的这件作品有点印象。当我更改For i As Integer = 0 To 10为小于 10 的任何数字时,它正在工作。

4

1 回答 1

0

正如上面提到的@Tilal,这个限制是由于 aspose 的评估版本。应用适当的许可证后,我可以在文档中插入 10+ 行。

干杯。

于 2017-05-12T23:55:31.850 回答