简体   繁体   中英

How use C# to export all Onenote pages to mht file

I have an Onenote note, which contains 3 sections and 2 pages for each, ie totally there are 6 pages.

How should I write C# code to automatically export all those 6 pages to 6 mht files?

You can use the OneNote API .

The REST API lets you read the sections, see the notes in them, and export the notes in HTML (with some limitations, like lack of math and handwriting support).

Microsoft provides code samples , you can see if there's anything you can use there.

Jadeson, if your notebooks exist in Office 365 or OneDrive, you may use the service API as Ezhik suggests. If they do not and you have a Win32 OneNote installation, you may use the OneNote COM API - https://github.com/OneNoteDev/VanillaAddIn . It is in C# and you can find documentation for that actual APIs here: https://msdn.microsoft.com/en-us/library/office/jj680120.aspx

In case neither MS Interop nor OneNote API is an option for you, look on proprietary Aspose.Note . To use it you need to explicitly set the path for each OneNote document (Section) and then extract necessary data or probably directly export it to HTML:

Document doc = new Document("in.one");
doc.Save("out.html");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM