This project has moved and is read-only. For the latest updates, please go here.

Removing Tables from Template

Sep 29, 2014 at 8:16 AM
Is it possible to remove tables from a template?

I am using this code:
private static void DoSomething()
{
    DocX doc = DocX.Load("../../test_template.docx");

    doc.ReplaceText("{operator}", "סלקום");
    doc.ReplaceText("{date}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
    doc.ReplaceText("{siteDesc}", "This is some long and boring site description");

    doc.Tables.Remove(doc.Tables[0]);
    doc.Tables.Remove(doc.Tables[0]);
    doc.Tables.Remove(doc.Tables[0]);

    doc.SaveAs("../../test_document.docx");              
}
But in test_document.docx I still see the same tables.

Do I need to do anything else or is this feature not supported?

Thanks!
Sep 30, 2014 at 9:00 AM
Does it work if you change your code to this instead?
...
    doc.Tables[0].Remove();
...
Marked as answer by tomercagan on 9/30/2014 at 1:02 AM
Sep 30, 2014 at 9:02 AM
Thanks - I was just playing some more with the library today and found that out :-)