Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Mon Dec 11, 2017 5:45 pm

Hi,

I suddenly do get a strange "ArgumentOutOfRangeException"-error when I want to count the numbers of pages in a document using GetPageCount.

The weird part is, that I do only add a Table to the document. I put in some message boxes to determine the exact line. Here my code snippet:
Code: Select all
        Aktuelle_TabelleNr = Zieldokument.Sections(Aktuelle_Sektion).Tables.Count
        MsgBox(Dokument.GetPageCount)-----------> Here it still works
        Zieldokument.Sections(Aktuelle_Sektion).AddTable()
        MsgBox(Dokument.GetPageCount)-----------> Thats were I get the error
        Dim Tabelle As Table = Zieldokument.Sections(Aktuelle_Sektion).Tables(Aktuelle_TabelleNr)


The message StackTrace contains:
bei System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
bei System.Collections.Generic.List`1.System.Collections.IList.get_Item(Int32 index)
bei Spire.Doc.Collections.RowCollection.get_Item(Int32 index)
bei spr6131.1()
bei spr6131..ctor(Paragraph A_0)
bei Spire.Doc.Documents.Paragraph.CreateLayoutInfo()
bei Spire.Doc.DocumentBase.Spire.Doc.Layout.IDocumentBase.get_LayoutInfo()
bei spr10261.2(Paragraph A_0)
bei spr10261.5(spr8883 A_0)
bei spr10261.10(spr8883 A_0)
bei spr10261.0(RectangleF A_0)
bei spr10261.4(spr8883 A_0)
bei spr10261.0(RectangleF A_0)
bei spr5861.0(spr7972 A_0, spr6881 A_1, spr7961 A_2)
bei spr5310.18()
bei spr5310.0(Document A_0)
bei Spire.Doc.Document.59()
bei Spire.Doc.Document.GetPageCount()

Do you need any more Details?

Best Regards
Christoph

c.carstensen
 
Posts: 2
Joined: Wed Feb 08, 2017 1:27 pm

Tue Dec 12, 2017 2:34 am

Hello Christoph,

Thanks for your inquiry. When adding a table, you need to set the row number and column number at the same time, then Spire.Doc will be able to calculate the page count.
Code: Select all
table.ResetCells(1,1)


Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Tue Dec 12, 2017 8:45 am

Hello Simon,

thank you for your repsonse. I tried your code, but it doesnt work. I still get the same error.

Best regards
Christoph

c.carstensen
 
Posts: 2
Joined: Wed Feb 08, 2017 1:27 pm

Tue Dec 12, 2017 9:17 am

Hello Christoph,

Thanks for your prompt feedback. I am using Spire.Doc Pack(hot fix) Version:6.0.71, if your are using an older version, please update the latest one and try again. If the issue still exists, please share us with your full code and Word document for further investigation.
Code: Select all
         Dim doc As New Document()
         doc.LoadFromFile("sample.docx")
         MessageBox.Show(doc.GetPageCount() & "")
         doc.Sections(0).AddTable().ResetCells(1, 1)
         MessageBox.Show(doc.GetPageCount() & "")


Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Thu Dec 14, 2017 10:08 am

Hello,

Greeting from E-iceblue.
How is the issue going?
Your feedback will be greatly appreciated.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Return to Spire.Doc