使用下面的代码,我最多可以添加 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
例外: [
堆栈跟踪:
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 的任何数字时,它正在工作。