I am trying to load SpreadJS using Jsdom, But it is giving error: need a browser which full supports HTML5 Canvas to run SpreadJS.
Where as jsom doc says it supports canvas.
I have installed canvas-prebuilt for jsom.
This is the code I have done so far:
index.js
const jsdom = require("jsdom");
const { JSDOM } = jsdom;
const options = {
resources: 'usable',
runScripts: 'dangerously',
};
JSDOM.fromFile('index.html', options).then((dom) => {
setTimeout(() => {
console.log(dom.window.document.body.textContent.trim());
}, 1000);
});
index.html
<!DOCTYPE html>
<html>
<head>
<title>SpreadJS ExcelIO</title>
<script src="libs/jquery-2.1.3.min.js" type="text/javascript"></script>
<script src="libs/jquery-ui.min.js" type="text/javascript"></script>
<link href="libs/gc.spread.sheets.excel2013white.10.1.0.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="libs/gc.spread.sheets.all.10.1.0.min.js"></script>
<script type="text/javascript" src="libs/gc.spread.excelio.10.1.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var workbook = new GC.Spread.Sheets.Workbook(document.getElementById("ss"));
var worksheet = workbook.getActiveSheet();
worksheet.getCell(3,3).value("SpreadJS");
worksheet.getCell(5,5).value("SpreadJS");
worksheet.getCell(7,7).value("SpreadJS");
});
</script>
</head>
<body>
<div id="ss" style="height:600px ; width :100%; ">sss</div>
</body>
</html>
Your help will be highly appreciated.
You should be able to change the code slightly to get the Spread object or the information in it.
index.html:
index.js: