none
I do not know how to add a row to a particular table with "OneNote Add-in". RRS feed

  • Question

  • If there is more than one table on OneNote's page, you can not add a row to a particular table using the script below.

    <script>
        Office.initialize = function(reason){}
        $(function(){
            $("#btnOK").click(function(){
                OneNote.run(function(context) {
                    var app = context.application;
                    var outline = app.getActiveOutline();
                    context.load(outline, "paragraphs, paragraphs/type");
                    return context.sync().then(function () {
                        var paragraphs = outline.paragraphs;
                        for (var i = 0; i < paragraphs.items.length; i++) {
                            var paragraph = paragraphs.items[i];
                            if (paragraph.type == "Table") {
                                var table = paragraph.table;
                                var row = table.appendRow(["Hello World!"]);
                            }
                        }
                        return context.sync();
                    })
                });
            });
        });
    </script>

    Looking at the official document, there seems to be a table ID, but I do not know how to use it.

    I want to know how to add a row to a specified table when OneNote's page has more than one table.

    Tuesday, October 30, 2018 7:18 AM

All replies