原創(chuàng)|產(chǎn)品更新|編輯:李顯亮|2020-02-19 13:33:34.320|閱讀 487 次
概述:Aspose.Slides For .Net更新至v20.2,支持獲取表格單元格文本框架內(nèi)的文字和部分的大小,允許直接在源文檔上更新自定義文檔屬性,修復(fù)轉(zhuǎn)換為PDF的時間過長等問題,歡迎下載體驗。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
Aspose.Slides for .NET是一個獨特的演示處理API,它允許應(yīng)用程序讀取、寫入、修改和轉(zhuǎn)換PowerPoint演示文稿。作為一個獨立的API,它提供了管理PowerPoint關(guān)鍵功能的功能,如管理文本、形狀、表格和動畫、向幻燈片添加音頻和視頻、預(yù)覽幻燈片等,而不需要Microsoft PowerPoint。
Aspose.Slides for .NET迎來2020年2月更新 v20.2,支持獲取表格單元格文本框架內(nèi)的文字和部分的大小,允許直接在源文檔上更新自定義文檔屬性,修復(fù)轉(zhuǎn)換為PDF的時間過長等問題。(點擊下方按鈕即可下載)
key | 概述 | 類別 |
---|---|---|
SLIDESNET-41674 | 從PPT到PDF的轉(zhuǎn)換速度極慢 | 功能 |
SLIDESNET-40977 | 支持獲取表格單元格文本框架內(nèi)的文字和部分的大小 | 功能 |
SLIDESNET-36546 | 支持直接在源文檔上更新自定義文檔屬性 | 功能 |
新功能演示——獲取表格單元格中的文本位置
添加的方法:
假設(shè)我們有一個表格,里面有一些文本,附近有一個簡單的AutoShape。
下面的代碼片段生成了這些對象:
using (Presentation pres = new Presentation()){ITable tbl = pres.Slides[0].Shapes.AddTable(50, 50, new double[] { 50, 70 }, new double[] { 50, 50, 50 });IParagraph paragraph0 = new Paragraph(); paragraph0.Portions.Add(new Portion("Text "));IParagraph paragraph1 = new Paragraph();paragraph0.Portions.Add(new Portion("in0")); paragraph0.Portions.Add(new Portion(" Cell")); paragraph1.Text = "On0";paragraph2.Portions.Add(new Portion("col0"));IParagraph paragraph2 = new Paragraph(); paragraph2.Portions.Add(new Portion("Hi there ")); ICell cell = tbl.Rows[1][1]; cell.TextFrame.Paragraphs.Clear();IAutoShape autoShape = pres.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 400, 100, 60, 120);cell.TextFrame.Paragraphs.Add(paragraph0); cell.TextFrame.Paragraphs.Add(paragraph1); cell.TextFrame.Paragraphs.Add(paragraph2); autoShape.TextFrame.Text = "Text in shape";}
下面的源代碼片段將在所有段落中添加一個黃色框,并在包含子字符串“ 0”的所有部分中添加一個藍(lán)框。
1)首先,我們獲得表格單元格左上角的坐標(biāo):
double x = tbl.X + cell.OffsetX;double y = tbl.Y + cell.OffsetY;
2)然后,我們使用IParagrap.GetRect()和IPortion.GetRect()方法向部分和段落添加框架:
foreach (IParagraph para in cell.TextFrame.Paragraphs){ if (para.Text == "") continue;IAutoShape shape =RectangleF rect = para.GetRect();rect.X + (float)x, rect.Y + (float)y, rect.Width, rect.Height);pres.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle,shape.LineFormat.FillFormat.SolidFillColor.Color = Color.Yellow;shape.FillFormat.FillType = FillType.NoFill; shape.LineFormat.FillFormat.FillType = FillType.Solid;rect = portion.GetRect();foreach (IPortion portion in para.Portions) { if (portion.Text.Contains("0")) { shape =shape.FillFormat.FillType = FillType.NoFill;pres.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, rect.X + (float)x, rect.Y + (float)y, rect.Width, rect.Height); } }}
3)現(xiàn)在,我們應(yīng)該在AutoShape段落中添加一個框架:
foreach (IParagraph para in autoShape.TextFrame.Paragraphs){IAutoShape shape =RectangleF rect = para.GetRect();pres.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle,rect.X + autoShape.X, rect.Y + autoShape.Y, rect.Width, rect.Height);shape.LineFormat.FillFormat.SolidFillColor.Color = Color.Yellow;shape.FillFormat.FillType = FillType.NoFill; shape.LineFormat.FillFormat.FillType = FillType.Solid;}
結(jié)果:
還想要更多嗎?您可以點擊閱讀【2019 · Aspose最新資源整合】,查找需要的教程資源。如果您有任何疑問或需求,請隨時加入Aspose技術(shù)交流群(642018183),我們很高興為您提供查詢和咨詢。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn