OneNote 2013 Interop使用代码将文本添加到创建的页面中
本文关键字:创建 添加 文本 Interop 2013 代码 OneNote | 更新日期: 2023-09-27 17:57:51
我最近一直在使用OneNote 2013 Interop创建一个加载项。我创建了一个新页面,我需要将文本从另一个页面复制到新创建的页面。我一直在谷歌上寻找答案,但似乎找不到适合我情况的答案。
OneNote 2013 Interop(非API)
我已经检查了XML结构,这就是我目前所拥有的。
我的问题看起来与以下问题非常相似:如何使用C#和OneNote Interop 写入OneNote 2013页面
我想添加一个链接,但我的帐户尚未验证。。。在stackoverflow中搜索该标题,你就会看到它。
但我的就像在新的一页中提到的那样。我现在所拥有的是,我在页面上创建元素,从而产生以下输出:
<one:Page xmlns:one="http://schemas.microsoft.com/office/onenote/2013/onenote" ID="{1384AF22-F63D-4880-9690-5C6038503D52}{1}{E1949529374926015356741973773722707113107541}" name="Page 3" dateTime="2016-07-20T05:49:31.000Z" lastModifiedTime="2016-07-20T05:49:31.000Z" pageLevel="2">
<one:QuickStyleDef index="0" name="PageTitle" fontColor="automatic" highlightColor="automatic" font="Calibri Light" fontSize="20.0" spaceBefore="0.0" spaceAfter="0.0" />
<one:PageSettings RTL="false" color="automatic">
<one:PageSize>
<one:Automatic />
</one:PageSize>
<one:RuleLines visible="false" />
</one:PageSettings>
<one:Title lang="nl-BE">
<one:OE author="Vince Eeckhout" authorInitials="VE" authorResolutionID="<resolutionId provider="Windows Live" hash="EkqFbCZ8WfIDi9LBAf7kjA=="><localId cid="1c606a1f4bf7dc24"/></resolutionId>" lastModifiedBy="Vince Eeckhout" lastModifiedByInitials="VE" lastModifiedByResolutionID="<resolutionId provider="Windows Live" hash="EkqFbCZ8WfIDi9LBAf7kjA=="><localId cid="1c606a1f4bf7dc24"/></resolutionId>" creationTime="2016-07-20T05:49:31.000Z" lastModifiedTime="2016-07-20T05:49:31.000Z" objectID="{D7A808C9-11B4-4A6C-BA23-C45EFB6722A8}{15}{B0}" alignment="left" quickStyleIndex="0">
<one:T>Page 3</one:T>
</one:OE>
</one:Title>
<one:Outline objectID="{A4942397-ED76-488C-91B8-CC0A0A5BEA4B}{10}{B0}">
<one:Position x="36.0" y="86.4000015258789" z="0">
<one:Size width="143.5806274414062" height="13.42771339416504">
<one:OEChildren>
<one:OE>
<one:T><![CDATA[I'm content of the page]]></one:T>
</one:OE>
</one:OEChildren>
</one:Size>
</one:Position>
</one:Outline>
</one:Page>
当我查看现有页面的结构时,xml如下所示:
<one:Page xmlns:one="http://schemas.microsoft.com/office/onenote/2010/onenote" ID="{D98A2E47-1AFB-06BD-2CF0-DFD632DCF8F1}{1}{E1820259626561303932420117111407808163080081}" name="Page 3" dateTime="2016-07-05T09:53:14.000Z" lastModifiedTime="2016-07-11T11:28:20.000Z" pageLevel="2" selected="partial" lang="nl-BE">
<one:QuickStyleDef index="0" name="PageTitle" fontColor="automatic" highlightColor="automatic" font="Calibri Light" fontSize="20.0" spaceBefore="0.0" spaceAfter="0.0" />
<one:QuickStyleDef index="1" name="p" fontColor="automatic" highlightColor="automatic" font="Calibri" fontSize="11.0" spaceBefore="0.0" spaceAfter="0.0" />
<one:PageSettings RTL="false" color="automatic">
<one:PageSize>
<one:Automatic />
</one:PageSize>
<one:RuleLines visible="false" />
</one:PageSettings>
<one:Title lang="nl-BE">
<one:OE author="Vince Eeckhout" authorInitials="VE" lastModifiedBy="Vince Eeckhout" lastModifiedByInitials="VE" creationTime="2016-07-05T09:53:20.000Z" lastModifiedTime="2016-07-05T09:53:20.000Z" objectID="{22153F4F-1C83-017C-056B-278E501AC009}{15}{B0}" alignment="left" quickStyleIndex="0">
<one:T><![CDATA[Page 3]]></one:T>
</one:OE>
</one:Title>
<one:Outline author="Vince Eeckhout" authorInitials="VE" lastModifiedBy="Vince Eeckhout" lastModifiedByInitials="VE" lastModifiedTime="2016-07-11T11:26:56.000Z" objectID="{A4942397-ED76-488C-91B8-CC0A0A5BEA4B}{10}{B0}">
<one:Position x="36.0" y="86.4000015258789" z="0" />
<one:Size width="143.5806274414062" height="13.42771339416504" />
<one:OEChildren>
<one:OE creationTime="2016-07-11T11:26:53.000Z" lastModifiedTime="2016-07-11T11:26:53.000Z" objectID="{A4942397-ED76-488C-91B8-CC0A0A5BEA4B}{11}{B0}" alignment="left" quickStyleIndex="1">
<one:T><![CDATA[I'm content of the page]]></one:T>
</one:OE>
</one:OEChildren>
</one:Outline>
</one:Page>
在我看来,这似乎是正确的,但当我想更新我的页面内容时,我遇到了一个错误:
元素'的上下文中不允许出现文本{http://schemas.microsoft.com/office/onenote/2013/onenote}位置'根据DTD/Schema
你能帮我做这个吗?
感谢您提前对此做出回应!:)
我在您的尝试中看到一些错误:
根据msonenote 2010方案,"one:Position"answers"one:Size"不得包含显示的内容。你把内容放在里面。最好的做法是让他们自我封闭。
此外,即使不是在您的情况下,title元素中的字符串也可能导致问题。因此,您应该避免直接在"one:T"元素中生成文本,而不是在"one:T"元素内生成"CDATA"元素。
如果将"位置元素"answers"大小元素"更改为自动闭合,则应该可以;)