簡體   English   中英

無法使用 ASPOSE Slides 設置表格單元格的邊距

[英]Can't set the margin of table cell using ASPOSE Slides

我在幻燈片中添加了一個表格,在表格中,我添加了一些帶有一些文本的行。 我面臨的問題是我無法減少單元格之間的間距/邊距。 我可以在打開 ppt 后設置 top margin-bottom margin 屬性,它可以很好地減少單元格之間的空間。 但同樣的事情是無法通過代碼實現的。 下面是我正在處理的示例代碼。 附件是我得到的ppt表格部分的截圖。 電流輸出

            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;

期望的輸出是應該減少單元格之間的空間。 請建議。

您能否分享您想要使用 Aspose.Slides 生成的所需輸出演示文件。 我將調查您的要求,並能夠在這方面進一步幫助您提供所要求的信息。

我還觀察了您的示例代碼,並且您正在使用 TextFrame 邊距。 我想在這里補充一點,當您使用表格單元格時,您需要直接設置表格單元格的邊距。 我建議您考慮在您的代碼中進行以下修改以觀察更改。

tblH[0, 0].MarginBottom=50f;

我在 Aspose 擔任支持開發人員/傳播者。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM