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.

Tue Jul 04, 2017 6:15 am

We can insert table into document at last,but how to insert into Table into fixed position?

jettbai
 
Posts: 1
Joined: Mon Jul 03, 2017 10:09 am

Tue Jul 04, 2017 7:06 am

Hello,

Thanks for your inquiry.
Please note that MS Word document is a flow document and does not contain any information about its layout into lines and pages. Concerning your situation, you can use bookmark to locate the postition; please refer to the following guidance:
1. First, insert a bookmark at that specific position, if there's already bookmark, just ignore this step and get to step2.
https://www.e-iceblue.com/Tutorials/Spire.Doc/Spire.Doc-Program-Guide/NET-Insert-Bookmark-Insert-Word-Bookmark-in-C-and-VB.NET.html

2. Move to that position and insert a table, and you just need to replace the image to table in the following example.
https://www.e-iceblue.com/Tutorials/Spire.Doc/Spire.Doc-Program-Guide/Bookmark/How-to-insert-an-image-at-bookmark-in-word-documents.html
Hope it helps. If there's still any doubt, please share your desired document with us so we can provide the solution accordingly.

Sincerely,
Jane
E-iceblue support team
User avatar

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

Tue Jul 11, 2017 8:43 am

Hello,

Did the solution I provided work?
Could you please give us some feedback at your convenience?

Many Thanks,
Jane
E-iceblue support team
User avatar

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

Wed Aug 29, 2018 3:58 am

Can you please provide a more specific code for your solution? I don't know how to add table to paragraph similar to these lines of code:
//Add a paragraph for section0
Paragraph paragraph = section0.AddParagraph();
Image image = Image.FromFile("step.png");
//Add a picture into paragraph
DocPicture picture = paragraph.AppendPicture(image);
Thank you!

anhnth
 
Posts: 1
Joined: Wed Aug 29, 2018 3:55 am

Wed Aug 29, 2018 6:56 am

Hello,

Thanks for your inquiry.
Below code shows how to insert a table at the position of bookmark. Please have a try. If it doesn't help, please provide your input and expected documents, then we will provide a solution accordingly.
Code: Select all
static void Main(string[] args)
{
    //Load Document from disk
    Document document = new Document();
    document.LoadFromFile("Sample.docx");

    //Insert Bookmark
    Section section = document.Sections[0];
    section.Paragraphs[3].AppendBookmarkStart("Spire");
    section.Paragraphs[4].AppendBookmarkEnd("Spire");

    //Move to bookmark
    BookmarksNavigator bn = new BookmarksNavigator(document);
    bn.MoveToBookmark("Spire", true, true);
    Section section0 = document.AddSection();
    Paragraph paragraph = section0.AddParagraph();

    //Create Table
    Table table=CreateTable(section0);

    //Insert the table at the position of bookmark
    bn.InsertTable(table);
   
    document.Sections.Remove(section0);
    document.SaveToFile("result.docx", FileFormat.Docx);
}
private static Table CreateTable(Section section)
{
    Table table=section.AddTable(true);
    table.ResetCells(3, 3);
    return table;
}

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Fri Aug 31, 2018 10:06 am

Hi,

Greetings from E-iceblue.
Has your issue been resolved?
Thanks in advance for your valuable feedback and time.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.Doc