无法使用 ASPOSE Slides 设置 table 单元格的边距
Can't set the margin of table cell using ASPOSE Slides
我在幻灯片中添加了 table,在 table 中添加了几行文字。我面临的问题是我无法减少单元格之间的 spacing/margins。我可以在打开 ppt 后设置 top margin-bottom margin 属性 并且它可以很好地减少单元格之间的 space 。但是同样的事情是无法通过代码实现的。下面是我正在处理的示例代码。附上我得到的ppt table部分的截图。
Current output
ISlide sld = press.Slides[0];
// Define columns with widths and rows with heights
double[] dblC = { 300, 300 };
double[] dblR = { 70, 70, 70 };
ITable tblH = sld.Shapes.AddTable(100, 82, dblC, dblR);
tblH.FirstRow = false;
tblH.Rows[0].MinimalHeight = 0;
tblH.Rows[1].MinimalHeight = 0;
tblH.Rows[2].MinimalHeight = 0;
ITextFrame txtFrame = tblH[0, 0].TextFrame;
txtFrame.TextFrameFormat.MarginBottom = 50f;
IParagraph paragraph = txtFrame.Paragraphs[0];
IPortion portion = paragraph.Portions[0];
portion.PortionFormat.LatinFont = new FontData("Arial");
portion.PortionFormat.FontBold = NullableBool.True;
portion.Text = "Some Text";
portion.PortionFormat.FillFormat.FillType = FillType.Solid;
portion.PortionFormat.FillFormat.SolidFillColor.Color = Color.Black;
portion.PortionFormat.FontHeight = 8;
ITextFrame txtFrame1 = tblH[0, 1].TextFrame;
txtFrame1.TextFrameFormat.MarginTop = 30f;
IParagraph paragraph1 = txtFrame1.Paragraphs[0];
IPortion portion1 = paragraph1.Portions[0];
portion1.PortionFormat.LatinFont = new FontData("Arial");
portion1.PortionFormat.FontBold = NullableBool.True;
portion1.Text = "Some Text";
txtFrame1.TextFrameFormat.ColumnSpacing = 5f;
portion1.PortionFormat.FillFormat.FillType = FillType.Solid;
portion1.PortionFormat.FillFormat.SolidFillColor.Color = Color.Black;
portion1.PortionFormat.FontHeight = 6;
ITextFrame txtFrame2 = tblH[0, 2].TextFrame;
txtFrame2.TextFrameFormat.MarginTop = 30f;
IParagraph paragraph2 = txtFrame2.Paragraphs[0];
IPortion portion2 = paragraph2.Portions[0];
portion2.PortionFormat.LatinFont = new FontData("Arial");
portion2.PortionFormat.FontBold = NullableBool.True;
portion2.Text = "Some Text";
portion2.PortionFormat.FillFormat.FillType = FillType.Solid;
portion2.PortionFormat.FillFormat.SolidFillColor.Color = Color.Black;
portion2.PortionFormat.FontHeight = 5;
期望的输出是应该减少单元格之间的 spaces。请提出建议。
能否分享您想要使用 Aspose.Slides 生成的所需输出演示文稿文件?我将调查您的要求,并能够在这方面进一步帮助您提供所要求的信息。
我还观察了您的示例代码,您使用的是 TextFrame 边距。我想在这里补充一点,当您使用 table 单元格时,您需要直接为 Table 单元格设置边距。我建议您考虑在您的代码中进行以下修改以观察更改。
tblH[0, 0].MarginBottom=50f;
我在 Aspose 担任支持开发人员/传播者。
我在幻灯片中添加了 table,在 table 中添加了几行文字。我面临的问题是我无法减少单元格之间的 spacing/margins。我可以在打开 ppt 后设置 top margin-bottom margin 属性 并且它可以很好地减少单元格之间的 space 。但是同样的事情是无法通过代码实现的。下面是我正在处理的示例代码。附上我得到的ppt table部分的截图。 Current output
ISlide sld = press.Slides[0];
// Define columns with widths and rows with heights
double[] dblC = { 300, 300 };
double[] dblR = { 70, 70, 70 };
ITable tblH = sld.Shapes.AddTable(100, 82, dblC, dblR);
tblH.FirstRow = false;
tblH.Rows[0].MinimalHeight = 0;
tblH.Rows[1].MinimalHeight = 0;
tblH.Rows[2].MinimalHeight = 0;
ITextFrame txtFrame = tblH[0, 0].TextFrame;
txtFrame.TextFrameFormat.MarginBottom = 50f;
IParagraph paragraph = txtFrame.Paragraphs[0];
IPortion portion = paragraph.Portions[0];
portion.PortionFormat.LatinFont = new FontData("Arial");
portion.PortionFormat.FontBold = NullableBool.True;
portion.Text = "Some Text";
portion.PortionFormat.FillFormat.FillType = FillType.Solid;
portion.PortionFormat.FillFormat.SolidFillColor.Color = Color.Black;
portion.PortionFormat.FontHeight = 8;
ITextFrame txtFrame1 = tblH[0, 1].TextFrame;
txtFrame1.TextFrameFormat.MarginTop = 30f;
IParagraph paragraph1 = txtFrame1.Paragraphs[0];
IPortion portion1 = paragraph1.Portions[0];
portion1.PortionFormat.LatinFont = new FontData("Arial");
portion1.PortionFormat.FontBold = NullableBool.True;
portion1.Text = "Some Text";
txtFrame1.TextFrameFormat.ColumnSpacing = 5f;
portion1.PortionFormat.FillFormat.FillType = FillType.Solid;
portion1.PortionFormat.FillFormat.SolidFillColor.Color = Color.Black;
portion1.PortionFormat.FontHeight = 6;
ITextFrame txtFrame2 = tblH[0, 2].TextFrame;
txtFrame2.TextFrameFormat.MarginTop = 30f;
IParagraph paragraph2 = txtFrame2.Paragraphs[0];
IPortion portion2 = paragraph2.Portions[0];
portion2.PortionFormat.LatinFont = new FontData("Arial");
portion2.PortionFormat.FontBold = NullableBool.True;
portion2.Text = "Some Text";
portion2.PortionFormat.FillFormat.FillType = FillType.Solid;
portion2.PortionFormat.FillFormat.SolidFillColor.Color = Color.Black;
portion2.PortionFormat.FontHeight = 5;
期望的输出是应该减少单元格之间的 spaces。请提出建议。
能否分享您想要使用 Aspose.Slides 生成的所需输出演示文稿文件?我将调查您的要求,并能够在这方面进一步帮助您提供所要求的信息。
我还观察了您的示例代码,您使用的是 TextFrame 边距。我想在这里补充一点,当您使用 table 单元格时,您需要直接为 Table 单元格设置边距。我建议您考虑在您的代码中进行以下修改以观察更改。
tblH[0, 0].MarginBottom=50f;
我在 Aspose 担任支持开发人员/传播者。