Unable to adjust the cells height and row height

Hi , i want to hide specific row inside tables in aspose word. how can i do that? and i also want to know that is it possible to adjust the font size of individual cells inside a row in a table

Hi Soe,

Thanks for your inquiry.

I think, there is no direct way that you can hide entire Word table row, instead you can use Row.Remove method as follows:

Row row = table.Rows[1];
row.Remove();

Secondly, yes of course, you can set the font/formatting for text of individual cells by using the following code snippet:

NodeCollection tables = doc.GetChildNodes(NodeType.Table, true);
Table table = (Table) tables[0];
Cell cell = table.Rows[0].Cells[0];
Paragraph paragraph = cell.Paragraphs[0];
Run run = paragraph.Runs[0];
// Set font formatting properties
Aspose.Words.Font font = run.Font;
font.Size = 20;
font.Bold = false;
font.Color = System.Drawing.Color.Green;
font.Name = "Verdana";
// Set paragraph formatting
ParagraphFormat paragraphFormat = paragraph.ParagraphFormat;
paragraphFormat.FirstLineIndent = 8;
paragraphFormat.Alignment = ParagraphAlignment.Justify;
paragraphFormat.KeepTogether = true;

Also, please see the following link for details about CellFormat property:
https://reference.aspose.com/words/net/aspose.words.tables/cell/cellformat/

I hope, this will help.

Best Regards,

Hi Awais,
Thanks for your reply. The code snippets you provided above is really helpful to figure out the issue i am facing. Another question is it is possible to adjust the height of the individual row inside a table? when i use row.rowFormat.Height = 0.01, it doesn’t work. The following is the code snippets. what i intend to do is i
want to reduce the height of some rows inside a table.

for (int i = 0; i <intCellCount; i++)
{
    for (int j = 0; j <row.Cells[i].Paragraphs.Count; j++)
    {
        for (int k = 0; k <row.Cells[i].Paragraphs[j].Runs.Count; k++)
        {
            row.Cells[i].Paragraphs[j].Runs[k].Font.Size = 0.01;
        }
    }
}
row.RowFormat.Height = 0.00;
row.RowFormat.HeightRule = HeightRule.Exactly;

Appreciate your help. Thank you so much.

Hi,

Thanks for your request. Yes,you can use RowFormat.Height in order to get/set the height of the table row in points. However, while using the latest version of Aspose.Words i.e. 10.6.0, I managed to reproduce this issue (i.e. row.rowFormat.Height = 0.01 fails) on my side. I have logged this issue in our bug tracking system. Your request has also been linked to the appropriate issue and you will be notified as soon as it is resolved. Sorry for inconvenience.

Best Regards,

Hi Soe,

Regarding WORDSNET-5584, our product team has completed the work on your issue and has come to a conclusion that this issue and the undesired behaviour you’re observing is actually not a bug in Aspose.Words. So, we have closed this issue as ‘Not a Bug’.

We tried this in MS Word. We cannot set the Exact table row height to zero. MS Word always leaves a small amount. So this minimum is enforced at MS Word and Aspose.Words cannot make it smaller. If we can help you with anything else, please feel free to ask.

Best regards,