如何使用C#在已有的MS onenote页面上插入文本行

本文关键字:onenote 插入文本行 MS 何使用 | 更新日期: 2023-09-27 18:24:12

我想使用C#在onenote页面中添加行。制作一个页面是已知的,但我找不到在现有的一个注释页面上插入行。

如何使用C#在已有的MS onenote页面上插入文本行

我假设您谈论的是OneNote REST API。若要将文本行添加到OneNote中的现有页面,可以使用PATCH API。以下是官方文档的链接:http://dev.onenote.com/docs#/reference/patch-页面

你的请求应该是这样的:

PATCH ~/me/notes/pages/{PAGEID}
Content-Type: application/json
Body:
[
{
   "target":"body",
   "action":"append",
   "position":"after",
   "content":"MySentenceHtmlContent"
}
]

如果你有任何问题,请告诉我!Jorge

我有一个在现有OneNote页面中插入文本行的解决方案。使用XML格式,列出如下

    public static string SetPageContent(string pageId, string msg)
    {
        string xml;
        onenoteApp.GetPageContent(pageId, out xml, PageInfo.piAll);
        var doc = XDocument.Parse(xml);
        // make newline with msg input
        XElement text = new XElement(ns + "OE",
            new XElement(ns + "T",
                new XCData(msg)));
        // insert new line
        doc.Root.Element(ns + "Outline").Element(ns + "OEChildren").Add(text);
        // Now update the page content
        onenoteApp.UpdatePageContent(doc.ToString());
        return null;
    }