原創(chuàng)|行業(yè)資訊|編輯:李顯亮|2019-10-08 13:46:32.600|閱讀 396 次
概述:Aspose.Slides for .NET更新至最新版v19.9,本文接著給大家介紹有一些非常有趣且實(shí)用的功能——使用自定義編號(hào)列表管理段落,接下來通過一些簡(jiǎn)單的示例來為大家說明一下!
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
Aspose.Slides for .NET是獨(dú)特的演示處理API,使應(yīng)用程序能夠讀取,編寫,修改和轉(zhuǎn)換PowerPoint演示文稿。作為獨(dú)立的API,它提供了管理PowerPoint關(guān)鍵功能的功能,例如管理文本,形狀,表格和動(dòng)畫,向幻燈片添加音頻和視頻,預(yù)覽幻燈片等等。
Aspose.Slides for .NET更新至最新版v19.9,本文接著給大家介紹有一些非常有趣且實(shí)用的功能——使用自定義編號(hào)列表管理段落,接下來通過一些簡(jiǎn)單的示例來為大家說明一下!
點(diǎn)擊下載最新版Aspose.Slides for .NET
致改變世界的程序員——現(xiàn)在購買Aspose系列產(chǎn)品最高可享10000元高額減免!更多活動(dòng)詳情可哦~
為了在段落內(nèi)添加自定義數(shù)字列表,首先需要訪問幻燈片并添加自動(dòng)形狀。然后,必須訪問形狀的相應(yīng)TextFrame并刪除其中的默認(rèn)段落。接著,需要使用Paragraph類創(chuàng)建一個(gè)新的段落實(shí)例,并將NumberedBulletStartWith設(shè)置為2,將第二個(gè)段落實(shí)例設(shè)置為NumberedBulletStartWith 3。
下面的代碼示例演示如何使用自定義編號(hào)列表設(shè)置段落。
//文檔目錄的路徑。
string dataDir = RunExamples.GetDataDir_Text();
using (var presentation = new Presentation())
{
var shape = presentation.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 200, 200, 400, 200);
//訪問創(chuàng)建的自動(dòng)形狀的文本框架
ITextFrame textFrame = shape.TextFrame;
//刪除默認(rèn)的現(xiàn)有段落
textFrame.Paragraphs.RemoveAt(0);
//第一個(gè)清單
var paragraph1 = new Paragraph { Text = "bullet 2" };
paragraph1.ParagraphFormat.Depth = 4;
paragraph1.ParagraphFormat.Bullet.NumberedBulletStartWith = 2;
paragraph1.ParagraphFormat.Bullet.Type = BulletType.Numbered;
textFrame.Paragraphs.Add(paragraph1);
var paragraph2 = new Paragraph { Text = "bullet 3" };
paragraph2.ParagraphFormat.Depth = 4;
paragraph2.ParagraphFormat.Bullet.NumberedBulletStartWith = 3;
paragraph2.ParagraphFormat.Bullet.Type = BulletType.Numbered;
textFrame.Paragraphs.Add(paragraph2);
var paragraph5 = new Paragraph { Text = "bullet 7" };
paragraph5.ParagraphFormat.Depth = 4;
paragraph5.ParagraphFormat.Bullet.NumberedBulletStartWith = 7;
paragraph5.ParagraphFormat.Bullet.Type = BulletType.Numbered;
textFrame.Paragraphs.Add(paragraph5);
presentation.Save(dataDir + "SetCustomBulletsNumber-slides.pptx", SaveFormat.Pptx);
}與此類似的基于Java的示例:
//文檔目錄的路徑。
String dataDir = Utils.getDataDir(SetCustomBulletsNumber.class);
Presentation presentation = new Presentation();
try
{
//訪問第一張幻燈片
ISlide slide = presentation.getSlides().get_Item(0);
//添加和訪問Autoshape
IAutoShape aShp = slide.getShapes().addAutoShape(ShapeType.Rectangle, 200, 200, 400, 200);
//訪問創(chuàng)建的自動(dòng)形狀的文本框架
ITextFrame txtFrm = aShp.addTextFrame("");
//刪除默認(rèn)的現(xiàn)有段落
txtFrm.getParagraphs().clear();
//第一個(gè)清單
Paragraph paragraph1 = new Paragraph();
paragraph1.setText("bullet 2");
paragraph1.getParagraphFormat().setDepth((short)4);
paragraph1.getParagraphFormat().getBullet().setNumberedBulletStartWith((short)2);
paragraph1.getParagraphFormat().getBullet().setType(BulletType.Numbered);
txtFrm.getParagraphs().add(paragraph1);
Paragraph paragraph2 = new Paragraph();
paragraph2.setText("bullet 3");
paragraph2.getParagraphFormat().setDepth((short)4);
paragraph2.getParagraphFormat().getBullet().setNumberedBulletStartWith((short)3); // ADDED: bullet start with 3 per customer needs
paragraph2.getParagraphFormat().getBullet().setType(BulletType.Numbered); // FIXED: paragraph1 local variable type was set instead of paragraph2.
txtFrm.getParagraphs().add(paragraph2);
//第二個(gè)清單
Paragraph paragraph5 = new Paragraph();
paragraph5.setText("bullet 5");
paragraph5.getParagraphFormat().setDepth((short)4);
paragraph5.getParagraphFormat().getBullet().setNumberedBulletStartWith((short)5);
paragraph5.getParagraphFormat().getBullet().setType(BulletType.Numbered);
txtFrm.getParagraphs().add(paragraph5);
presentation.save(dataDir + "SetCustomBulletsNumber-slides.pptx.pptx", SaveFormat.Pptx);
} finally {
if (presentation != null) presentation.dispose();
}ASPOSE技術(shù)交流QQ群(642018183)已開通,各類資源及時(shí)分享,歡迎交流討論!
掃描關(guān)注“慧聚IT”微信公眾號(hào),及時(shí)獲取更多產(chǎn)品最新動(dòng)態(tài)及最新資訊

本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@ke049m.cn