none
How to get the excel sheet name in Office 2013 Excel Addin RRS feed

  • Question

  • Hi, 

    Could any one please help me, with the code to read the Excel sheet name in Office 2013 Excel Addin, using javascript.

    I believe, Excel.run(function (ctx) is not supported in Office 2013, please correct me if I am wrong.

    Thanks,



    • Edited by PDEdev Wednesday, April 20, 2016 4:05 PM
    Wednesday, April 20, 2016 3:58 PM

Answers

  • Hi, 

    >>I believe, Excel.run(function (ctx) is not supported in Office 2013, please correct me if I am wrong.

    You are correct. The new version of Excel API only support for Excel 2016. And here is an example that get the active worksheet name using the new version Excel API:

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

    If you also want this feature support for Office 2013, you can try to submit the feedback from here.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, May 4, 2016 9:35 AM
    Moderator

All replies

  • Hi

    In Office.js, the worksheet object has a name property with which you can get the name of the worksheet.

    Check this link for further help on how to use the Office.js

    Office Dev Reference


    Wednesday, April 20, 2016 7:51 PM
  • Hi, 

    >>I believe, Excel.run(function (ctx) is not supported in Office 2013, please correct me if I am wrong.

    You are correct. The new version of Excel API only support for Excel 2016. And here is an example that get the active worksheet name using the new version Excel API:

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

    If you also want this feature support for Office 2013, you can try to submit the feedback from here.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, May 4, 2016 9:35 AM
    Moderator