Search code examples
asposeaspose.words

Aspose.Word - How to make use of full table cell width?


I have a table in a word document and would like to make use of FULL cell width to insert data.

Default behaviour is that it is leaving spaces (padding) as below. enter image description here

How can i make use of the total width of a column without leaving any space?


Solution

  • You can use Aspose.Words to adjust amount of space (in points) to the left, right, below or above the contents of cells. Please try using the following code:

    Document doc = new Document(MyDir + @"input.docx");
    
    Table tab = doc.FirstSection.Body.Tables[0];
    
    tab.BottomPadding = 0;
    tab.LeftPadding = 0;
    tab.RightPadding = 0;
    tab.TopPadding = 0;
    
    doc.Save(MyDir + @"17.7.docx");
    

    Hope, this helps.

    I work with Aspose as Developer Evangelist.