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.

Thu Jan 10, 2019 10:51 am

Good day


I was having a issue regarding the landscape of a doc file.

when I was trying to have a landscape on a doc and put a table on it
It seems like the code

Table table = doc.Sections[0].Tables[4] as Spire.Doc.Table;

is not working, spire.doc wasn't able to find the table when in landscape mode but when I return it back to portrait mode, the code finds the table.

tcballelos
 
Posts: 36
Joined: Wed Nov 28, 2018 5:35 am

Fri Jan 11, 2019 2:06 am

Hi,

Thank you for your inquiry.
After testing, I would get the table object successfully.
Please share your complete code and the file(if any) for further investigation.

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Wed Jan 16, 2019 5:54 am

Hi Good day!


Sorry for the late reply. The example is attached below
The first page is portrait, while second page is landscape

Here's the code

Table table = doc.Sections[0].Tables[4] as Spire.Doc.Table;


The table in the landscape(which is index number 4) wasn't able to fill a data.

tcballelos
 
Posts: 36
Joined: Wed Nov 28, 2018 5:35 am

Wed Jan 16, 2019 9:02 am

Hi,

Thanks for your inquiry.
After checking your document, I find there are two sections in your file. The table on the landscape page is in the second section, so please use below code to access it.
Code: Select all
Table table = doc.Sections[1].Tables[0] as Spire.Doc.Table;


Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Fri Jan 18, 2019 6:54 am

Hi,

Greetings from E-iceblue.
Has your issue been resolved? Could you please give us some feedback at your convenience?

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Sat Apr 25, 2020 10:03 pm

Hi,

Do you have a document or an article on how a word document is sectioned?

The reason I ask is that, how do I know an element in my word document is in which section.

Thank you!

MicroGenDX
 
Posts: 2
Joined: Fri Mar 22, 2019 9:46 pm

Sun Apr 26, 2020 7:04 am

Hi Richard,

Thanks for your inquiry.
Generally, to determine which section the element is in, you need to analyze it according to the internal structure of the document. To help us investigate your issue more accurately and quickly, please share your input file with us. You could upload here or send it to us(support@e-iceblue.com) via email.
Meanwhile, I made a simple demo for you, and attached is my input document, you could test it with the latest Spire.Doc Pack(hot fix) Version:8.4.7.
Code: Select all
    Document doc = new Document();
    doc.LoadFromFile("test.docx");

    //Get the section of the table
    Table table = doc.Sections[0].Tables[0] as Table;           
    Section tableSection = table.Owner.Owner as Section;

    //Get the section of the table cell
    TableCell cell = table.Rows[0].Cells[0];
    Section cellSection = cell.Owner.Owner.Owner.Owner as Section;

    //Get the section of the paragraph
    Paragraph para1 = doc.Sections[0].Paragraphs[1];
    Section paragraphSection = para1.Owner.Owner as Section;

    //Get the section of the picture
    Paragraph para2 = doc.Sections[1].Paragraphs[1];
    foreach (DocumentObject docObj in para2.ChildObjects)
    {
        if (docObj.DocumentObjectType == DocumentObjectType.Picture)
        {
            DocPicture picture = docObj as DocPicture;
            Section pcitureSection = picture.OwnerParagraph.Owner.Owner as Section;
        }
    }


Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.Doc