Есть ли способ получить содержимое Excel в виде HTML / текста, как надстройка Word? - PullRequest
0 голосов
/ 02 января 2019

Я использовал образец Excel кода, чтобы получить Excel, используя add-in:

async function run() {
    try {
            await Excel.run(async context => {

                // const range = context.workbook.getSelectedRange();

                const sheetName = 'Sheet1';
                const rangeAddress = 'F1:F20';
                const worksheet = context.workbook.worksheets.getItem(sheetName);
                const range = worksheet.getRange(rangeAddress);
                range.load('text');

                await context.sync();
                console.log(range.text);
            });
        } catch(error) {
            OfficeHelpers.UI.notify(error);
            OfficeHelpers.Utilities.log(error);
        };
}

Здесь он дает вам массив данных для F столбца в Excel.

Разве нет способа получить все worksheet как HTML или Text как то, что мы делаем в надстройке Word:

// Run a batch operation against the Word object model.
Word.run(function (context) {

    // Create a proxy object for the document body.
    var body = context.document.body;

    // Queue a commmand to get the HTML contents of the body.
    var bodyHTML = body.getHtml();

    // Synchronize the document state by executing the queued commands,
    // and return a promise to indicate task completion.
    return context.sync().then(function () {
        console.log("Body HTML contents: " + bodyHTML.value);
    });
})
.catch(function (error) {
    console.log("Error: " + JSON.stringify(error));
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

Я ценюесли бы кто-то мог пролить свет на этот вопрос.

...