is it possible to create new worksheet in Excel 2013 using Office.js in Office Apps ??

787 Views Asked by At

I am developing task pane Office Apps in excel 2013. As part it , I have to create a new worksheet in Excel 2013 using Office.js .

Do we have any new sheet creating utility/function in Office.JS for Excel 2013 ???? or any alternate solution readily available for this ??

Please respond to my post asap as this impacts our current development.

Regards,

Ram

3

There are 3 best solutions below

0
On

No, I've not found a way of doing this, but my work around has been to start with a template Excel file with plenty of sheets already in it.

0
On

As far as I know, there are no such kind of feature in current Office JavaScript API. But you should be able to post a feature request to Office Development Platform User voice.

http://officespdev.uservoice.com

0
On

In Excel 2016 you can use the add method in the WorksheetCollection object.

Excel.run(function (ctx) { 
    var wSheetName = 'Sample Name';
    var worksheet = ctx.workbook.worksheets.add(wSheetName);
    worksheet.load('name');
    return ctx.sync().then(function() {
        console.log(worksheet.name);
    });
}).catch(function(error) {
        console.log("Error: " + error);
        if (error instanceof OfficeExtension.Error) {
            console.log("Debug info: " + JSON.stringify(error.debugInfo));
        }
});

Source: https://dev.office.com/reference/add-ins/excel/worksheetcollection