How to change height of a row in a table

Hi all,

I am trialing Aspose.Slides with a full trial licence.

Using the Aspose sample code I just wish to change the row height of tables from 30 to 20 but for some reason this was not possible. I would expect to change the original line in red from
double[] dblRows = { 50, 30, 30, 30, 30 }; to double[] dblRows = { 50, 20, 20, 20, 20 };
However, this simple setting was not possible and the row height did not appear to change. I must be doing something silly? Please advise guys, thanks.

The default Aspos sample is as below:

using System.IO;

using Aspose.Slides;
using System.Drawing;

namespace CSharp.Tables
{
public class TableFromScratch
{
public static void Run()
{
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Tables();

// Create directory if it is not already present.
bool IsExists = System.IO.Directory.Exists(dataDir);
if (!IsExists)
System.IO.Directory.CreateDirectory(dataDir);

//Instantiate Presentation class that represents PPTX file
using (Presentation pres = new Presentation())
{

//Access first slide
ISlide sld = pres.Slides[0];

//Define columns with widths and rows with heights
double[] dblCols = { 50, 50, 50 };
double[] dblRows = { 50, 30, 30, 30, 30 };

//Add table shape to slide
ITable tbl = sld.Shapes.AddTable(100, 50, dblCols, dblRows);

//Set border format for each cell
foreach (IRow row in tbl.Rows)
foreach (ICell cell in row)
{
cell.BorderTop.FillFormat.FillType = FillType.Gradient;
cell.BorderTop.FillFormat.SolidFillColor.Color = Color.Red;
cell.BorderTop.Width = 2;

cell.BorderBottom.FillFormat.FillType = FillType.Solid;
cell.BorderBottom.FillFormat.SolidFillColor.Color = Color.Red;
cell.BorderBottom.Width = 2;

cell.BorderLeft.FillFormat.FillType = FillType.Pattern;
cell.BorderLeft.FillFormat.SolidFillColor.Color = Color.Red;
cell.BorderLeft.Width = 2;

cell.BorderRight.FillFormat.FillType = FillType.Solid;
cell.BorderRight.FillFormat.SolidFillColor.Color = Color.Red;
cell.BorderRight.Width = 2;
}


//Merge cells 1 & 2 of row 1
tbl.MergeCells(tbl[0, 0], tbl[1, 0], false);


//Add text to the merged cell
tbl[0, 0].TextFrame.Text = “Merged Cells”;

//Write PPTX to Disk
pres.Save(dataDir + “table.pptx”, Aspose.Slides.Export.SaveFormat.Pptx);
}

}
}
}

Regards,
Anil

Hi Anil,


Thanks for inquiring Aspose.Slides.

I have observed your requirement and like to share that you can change the row height by individually changing the row height of every row. Please try using the following property on your end to alter the row height.


row.MinimalHeight = row.MinimalHeight +30;

I hope this will be helpful. Please share, if I may help you further in this regard.

Many Thanks,

Hi Mudassir,


Thanks for your tip. However, I wish my row height to be 20 but the code does not allow this for some reason. The minimum appears to be 30.

Regards,
Anil

Hi Anil,


I have observed your comments and like to share with you that minimum height of row is not 30. I have tried the following sample code on my end and have observed that there is a difference of row height. Setting the height row as 20 is working fine. I request you to please try using following sample code on your end and then share feedback with us if you can see the difference or the height is identical in both cases. I have attached the generated presentations as well as the snip of them to explain the difference, for your kind reference.

Presentation pres = new Presentation();
//Access first slide
ISlide sld = pres.Slides[0];
//Define columns with widths and rows with heights
double[] dblCols = { 50, 50, 50 };
double[] dblRows = { 50, 30, 30, 30, 30 };
//Add table shape to slide
ITable tbl = sld.Shapes.AddTable(50, 50, dblCols, dblRows);
pres.Save(@“D:\WidthRow30.pptx”, Aspose.Slides.Export.SaveFormat.Pptx);

pres = new Presentation();
//Access first slide
sld = pres.Slides[0];
//Define columns with widths and rows with heights
double[] dblColss = { 50, 50, 50 };
double[] dblRowss = { 50, 20, 20, 20, 20 };
//Add table shape to slide
tbl = sld.Shapes.AddTable(50, 50, dblColss, dblRowss);
pres.Save(@“D:\WidthRow20.pptx”, Aspose.Slides.Export.SaveFormat.Pptx);

I hope this will clarify the concept. Please share if I may help you further in this regard.

Best Regards,