在 OneNote 中創建項目符號或編號列表

以清晰和有序的方式組織資訊在筆記時是至關重要的。您可以通過在 OneNote 中添加項目符號或編號列表來使筆記更易於閱讀。列表幫助組織想法、分解任務並突出重要觀點。它們改善了筆記的結構,使掃描內容變得更加輕鬆。在本文中,您將學習如何使用 Java 在 OneNote 中添加和自定義項目符號和編號列表。我們還將探索如何以編程方式結構化您的內容。

這篇文章涵蓋以下主題:

C# OneNote SDK 創建 OneNote 中的項目符號或編號列表

我們將使用 Aspose.Note for .NET 來在 OneNote 文件中創建項目符號或編號列表。這是一個功能強大的庫,使創建 OneNote 中的項目符號和編號列表的過程變得簡單。它提供了強大的功能來操作 OneNote 文件,包括添加、編輯和格式化列表。使用 Aspose.Note,開發人員可以輕鬆地將 OneNote 功能集成到他們的應用程序中,使其成為 C# 程序員的有價值工具。

按照以下簡單步驟安裝 Aspose.Note for .NET:

  1. releases 下載庫。
  2. NuGet 安裝它,使用以下命令在套件管理器控制台中:
PM> Install-Package Aspose.Note

在 C# 中使用 OneNote 創建項目符號列表

請按照以下步驟使用 C# 和 Aspose.Note for .NET 在 OneNote 中創建項目符號列表:

  1. 創建一個新的 Document 類對象。
  2. 初始化 PageOutline 類別物件。
  3. 初始化 TextStyle 類別物件並設置格式屬性。
  4. 創建 OutlineElement 類對象並應用項目符號。
  5. 將大綱元素添加到 Outline 中,使用 AppendChildLast() 方法。
  6. 同樣地,將 Outline 添加到 Page,然後將 Page 添加到 Document
  7. 使用 Save() 方法保存 OneNote 文件。

請在下方找到一段完整的 C# 程式碼範例,展示這些步驟:

using Aspose.Note;

// 創建 Document 類的對象
Document doc = new Document();

// 初始化 Page 類的物件
Page page = new Page();

// 初始化 Outline 類別物件
Outline outline = new Outline();

// 初始化 TextStyle 類別物件並設置格式屬性
ParagraphStyle defaultStyle = new ParagraphStyle 
{ 
    FontColor = Color.Black, 
    FontName = "Arial", 
    FontSize = 10 
};

// 初始化 OutlineElement 類別對象並應用項目符號
OutlineElement outlineElem1 = new OutlineElement() 
{ 
    NumberList = new NumberList("*", "Arial", 10) 
};

// 初始化 RichText 類別物件並應用文字樣式
RichText text1 = new RichText() 
{ 
    Text = "First", 
    ParagraphStyle = defaultStyle 
};

outlineElem1.AppendChildLast(text1);

OutlineElement outlineElem2 = new OutlineElement() 
{ 
    NumberList = new NumberList("*", "Arial", 10) 
};

RichText text2 = new RichText() 
{ 
    Text = "Second", 
    ParagraphStyle = defaultStyle 
};

outlineElem2.AppendChildLast(text2);

OutlineElement outlineElem3 = new OutlineElement() 
{ 
    NumberList = new NumberList("*", "Arial", 10) 
};

RichText text3 = new RichText() 
{ 
    Text = "Third", 
    ParagraphStyle = defaultStyle 
};

outlineElem3.AppendChildLast(text3);

// 添加大綱元素
outline.AppendChildLast(outlineElem1);
outline.AppendChildLast(outlineElem2);
outline.AppendChildLast(outlineElem3);

// 添加大綱節點
page.AppendChildLast(outline);

// 添加頁面節點
doc.AppendChildLast(page);

// 保存 OneNote 文檔
doc.Save("ApplyBulletsOnText.one");
在 OneNote 中使用 C# 創建項目符號列表

在 C# 中使用 OneNote 創建項目符號列表

在 OneNote 中使用 C# 創建編號列表

按照之前提到的相同步驟在 OneNote 中插入編號列表。然而,使用 {0}) 來定義數字格式(例如,1)2) 等)而不是像 `` 這樣的項符號。

以下是完整的 C# 代碼示例,演示如何對文本應用編號。

using Aspose.Note;

// 創建 Document 類的對象
Document doc = new Document();

// 初始化 Page 類別物件
Aspose.Note.Page page = new Page();

// 初始化 Outline 類別物件
Outline outline = new Outline();

// 初始化 TextStyle 類別物件並設置格式化屬性
ParagraphStyle defaultStyle = new ParagraphStyle 
{ 
    FontColor = Color.Black, 
    FontName = "Arial", 
    FontSize = 10 
};

// 初始化 OutlineElement 類別對象並應用編號
// 同一大綱中的數字會自動遞增。
OutlineElement outlineElem1 = new OutlineElement() 
{ 
    NumberList = new NumberList("{0})", 
    NumberFormat.DecimalNumbers, "Arial", 10) 
};

RichText text1 = new RichText() 
{ 
    Text = "First", 
    ParagraphStyle = defaultStyle 
};

outlineElem1.AppendChildLast(text1);

OutlineElement outlineElem2 = new OutlineElement() 
{ 
    NumberList = new NumberList("{0})", 
    NumberFormat.DecimalNumbers, "Arial", 10) 
};

RichText text2 = new RichText() 
{ 
    Text = "Second", 
    ParagraphStyle = defaultStyle 
};

outlineElem2.AppendChildLast(text2);

OutlineElement outlineElem3 = new OutlineElement() 
{ 
    NumberList = new NumberList("{0})", 
    NumberFormat.DecimalNumbers, "Arial", 10) 
};

RichText text3 = new RichText() 
{ 
    Text = "Third", 
    ParagraphStyle = defaultStyle 
};

outlineElem3.AppendChildLast(text3);

// 添加大綱元素
outline.AppendChildLast(outlineElem1);
outline.AppendChildLast(outlineElem2);
outline.AppendChildLast(outlineElem3);

// 新增大綱節點
page.AppendChildLast(outline);
// 添加頁面節點
doc.AppendChildLast(page);

// 保存 OneNote 文件
doc.Save("ApplyNumberingOnText.one");
在 C# 中使用 OneNote 創建編號列表

使用 C# 在 OneNote 中創建編號列表

在 OneNote 中插入中文數字列表

請按照之前提到的相同步驟,在 OneNote 中使用 Aspose.Note for .NET 插入中文編號清單。不過,請使用 {0})NumberFormat.ChineseCounting 來定義編號格式。

這是一段 C# 代碼片段,演示如何應用中文編號列表:

using Aspose.Note;

Document doc = new Document();
Page page = new Page();
Outline outline = new Outline();

// 應用文本樣式設定
ParagraphStyle defaultStyle = new ParagraphStyle 
{ 
    FontColor = Color.Black, 
    FontName = "Arial", 
    FontSize = 10 
};

// 同一大綱中的編號會自動遞增。
OutlineElement outlineElem1 = new OutlineElement() 
{ 
    NumberList = new NumberList("{0})", 
    NumberFormat.ChineseCounting, "Arial", 10) 
};

RichText text1 = new RichText() 
{ 
    Text = "First", ParagraphStyle = defaultStyle 
};

outlineElem1.AppendChildLast(text1);


OutlineElement outlineElem2 = new OutlineElement() 
{ 
    NumberList = new NumberList("{0})", 
    NumberFormat.ChineseCounting, "Arial", 10) 
};

RichText text2 = new RichText() 
{ 
    Text = "Second", 
    ParagraphStyle = defaultStyle 
};

outlineElem2.AppendChildLast(text2);

OutlineElement outlineElem3 = new OutlineElement() 
{ 
    NumberList = new NumberList("{0})", 
    NumberFormat.ChineseCounting, "Arial", 10) 
};

RichText text3 = new RichText() 
{ 
    Text = "Third", 
    ParagraphStyle = defaultStyle 
};

outlineElem3.AppendChildLast(text3);

outline.AppendChildLast(outlineElem1);
outline.AppendChildLast(outlineElem2);
outline.AppendChildLast(outlineElem3);
page.AppendChildLast(outline);
doc.AppendChildLast(page);

// 保存 OneNote 文件
doc.Save("ChineseNumberList.one");
在 OneNote 中插入中文數字列表

在 OneNote 中插入中文数字列表

獲取免費授權

有興趣探索 Aspose 產品嗎?訪問 license page 以獲取免費的臨時許可證。開始使用非常簡單,您可以為您的項目解鎖 Aspose.Note 的全部潛力!

應用項目符號或編號於文本:免費資源

除了在 OneNote 文檔中應用項目符號或編號外,我們還提供各種資源來增強您對 Aspose.Note for .NET 的理解。請參閱我們的文檔和教程以獲取更多見解。

結論

在這篇部落格文章中,我們討論了如何使用 C# 在 OneNote 中創建項目符號和編號列表。使用 Aspose.Note for .NET,開發人員可以有效地實現這一功能,允許他們增強應用程序的結構化和格式良好的筆記內容。

如果您有任何問題或需要進一步的幫助,請隨時透過我們的 free support forum 與我們聯繫。

See Also