簡體   English   中英

表頭列背景顏色不變

[英]Table header column background color not changing

我在我的項目中使用 ASPOSE Slides 來執行 PPT 任務。 我想更改表格標題背景顏色,但在 Aspose 論壇中沒有找到任何解決方案。 任何人都可以為我提供解決方案嗎?

            ISlide sld = press.Slides[0];
            double[] dblCols = { 250, 250};
            double[] dblRows = { 70, 70, 70,70 };
            // Add table shape to slide
            ITable tbl = sld.Shapes.AddTable(100, 100, dblCols, dblRows);
            tbl[0, 1].TextFrame.Text = "some text";
            tbl[0, 2].TextFrame.Text = "some text";
            tbl[0, 3].TextFrame.Text = "some text";
            tbl[0, 3].BorderBottom.FillFormat.FillType = FillType.Solid;
            tbl[0, 3].FillFormat.SolidFillColor.BackgroundColor = Color.Blue;
            tbl[0,3].BorderBottom.Width = 2;

            Portion portion = (Portion)tbl[0, 1].TextFrame.Paragraphs[0].Portions[0];
            portion.PortionFormat.FillFormat.FillType = FillType.Solid;
            portion.PortionFormat.FillFormat.SolidFillColor.Color = Color.Black;

}

我觀察到您對設置表頭背景的要求。 請嘗試使用以下示例代碼,其中包含為標題行單元格之一設置填充顏色的示例。 您也可以為其他單元格復制相同的內容。

public static void TestTableBackground()
{
    Presentation press = new Presentation();
    ISlide sld = press.Slides[0];
    double[] dblCols = { 250, 250 };
    double[] dblRows = { 70, 70, 70, 70 };
    // Add table shape to slide
    ITable tbl = sld.Shapes.AddTable(100, 100, dblCols, dblRows);
    tbl[0, 1].TextFrame.Text = "some text";
    tbl[0, 2].TextFrame.Text = "some text";
    tbl[0, 3].TextFrame.Text = "some text";
    tbl[0, 0].FillFormat.FillType = FillType.Solid;
    tbl[0, 0].FillFormat.SolidFillColor.Color = Color.Blue;
   
    Portion portion = (Portion)tbl[0, 1].TextFrame.Paragraphs[0].Portions[0];
    portion.PortionFormat.FillFormat.FillType = FillType.Solid;
    portion.PortionFormat.FillFormat.SolidFillColor.Color = Color.Black;

    press.Save(@"C:\Aspose Data\TableFormat.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
}

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

暫無
暫無

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

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