Estoy tratando de crear un complemento de Excel con el generador Yeoman . En el archivo excel_project/src/taskpane/taskpane.js me gustaría llamar a la biblioteca ' fs '. Cuando ejecuto taskpane.js solo en mi terminal, todo funciona bien. Sin embargo, cuando inicio todo el proyecto de Excel ( npm start
en mi terminal) tengo un error de importación de módulo (ver imagen). Es como si los módulos no se pudieran importar en el complemento de Excel... ¿Alguien tiene alguna idea? Gracias por tu ayuda.
Aquí está el archivo taskpane.js , como si lo hubiera creado Yeoman. Acabo de agregar const fs = require('fs'); // this gives the error
Office.onReady((info) => { if (info.host === Office.HostType.Excel) { document.getElementById("sideload-msg").style.display = "none"; document.getElementById("app-body").style.display = "flex"; document.getElementById("run").onclick = run; } }); export async function run() { try { const fs = require('fs'); // this gives the error await Excel.run(async (context) => { const range = context.workbook.getSelectedRange(); let text = document.querySelector('textarea').value; // Read the range address range.load("address"); // Update the fill color range.format.fill.color = "yellow"; await context.sync(); console.log(`The range address was ${range.address}.`); }); } catch (error) { console.error(error); } }