EvotecIT / OfficeIMO

Fast and easy to use cross-platform .NET library that creates or modifies Microsoft Word (DocX) and later also Excel (XLSX) files without installing any software. Library is based on Open XML SDK
MIT License
263 stars 47 forks source link

Inserting Tables #172

Closed yuphevibing closed 7 months ago

yuphevibing commented 7 months ago

Would like to be able to insert a Table at a specific location in the document, not only at the end with the AddTable. Maybe expanding the FindAndReplace method so it would work with tables, or a AddTable method for sections could be solutions.

PrzemyslawKlys commented 7 months ago

Pretty sure you can add tables to paragraphs:

var table3 = paragraph1.AddTableAfter(4, 4, WordTableStyle.GridTable1LightAccent1);
table3.Rows[0].Cells[0].Paragraphs[0].Text = "Inserted in the middle of the document after paragraph";

var table4 = paragraph1.AddTableBefore(4, 4, WordTableStyle.GridTable1LightAccent1);
table4.Rows[0].Cells[0].Paragraphs[0].Text = "Inserted in the middle of the document before paragraph";