Description
Hi,
I am using exceljs in a html environment. I wanted to use addImage.
But as soon as i do that i get an exception.
i used the following code:
// add image to workbook by filename
var imageId1 = workbook.addImage({
filename: 'img/logo.jpeg',
extension: 'jpeg',
});
i am using the following require.js definitions
`
//Set the path to jQuery to local path
requirejs.config({
paths: {
jquery: 'js/jquery',
Excel: "js/exceljs_2017_07_16",
//Excel: "js/exceljs",
fs: "js/filesaver.min", // enables download of files within javascript - is used from exceljs
jszip: "js/jszip.min", // jszip is used to generate zip files - is used from exceljs
lodash: "js/lodash", // jszip is used to generate zip files - is used from exceljs
es6shim: "js/es6-shim" // jszip is used to generate zip files - is used from exceljs
}
});
require(['Excel', 'fs', 'jszip', 'lodash', 'es6shim', 'jquery' ], function (Excel, fileSaver) {
...
}
i get the message that fs.readFile is not a function
TypeError: fs.readFile is not a function
at http://localhost:8080/exceljsTest/js/exceljs_2017_07_16.js:10749:8
at lib$es6$promise$$internal$$initializePromise (http://localhost:8080/exceljsTest/js/exceljs_2017_07_16.js:14955:9)
at Promish.lib$es6$promise$promise$$Promise [as constructor] (http://localhost:8080/exceljsTest/js/exceljs_2017_07_16.js:15246:9)
at new Promish (http://localhost:8080/exceljsTest/js/exceljs_2017_07_16.js:35957:108)
at fsReadFileAsync (http://localhost:8080/exceljsTest/js/exceljs_2017_07_16.js:10748:10)
at http://localhost:8080/exceljsTest/js/exceljs_2017_07_16.js:11086:18
at Array.map (native)
at 85.module.exports.addMedia (http://localhost:8080/exceljsTest/js/exceljs_2017_07_16.js:11082:47)
at http://localhost:8080/exceljsTest/js/exceljs_2017_07_16.js:11311:21
at lib$es6$promise$$internal$$tryCatch (http://localhost:8080/exceljsTest/js/exceljs_2017_07_16.js:14908:16)
`
The following code inside of exceljs (line 10749) is used (with a reference to fs.
function fsReadFileAsync(filename, options) { return new PromishLib.Promish(function (resolve, reject) { fs.readFile(filename, options, function (error, data) { if (error) { reject(error); } else { resolve(data); } }); }); }
What is the way to attach fs = What library do i have to include ? i am sure i can't include node.js :)
Thanks and best regards
Manfred