0
我試圖使用XLSX庫來讀取excelsheet數據,但我得到這個: -當使用XLSX解析excelsheet - 它是扔_fs是不確定的
ERROR: _fs is undefined at xlsx.js (line 11388, col 59)
這裏是我的代碼: -
<html>
<head>
<title>Read Excel</title>
<meta meta http-equiv="Content-Type" content="text/html;" charset="UTF-8"/>
</head>
<body>
<script src="xlsx.js"></script>
<script>
function actionbegins(){
console.log("Inside the function action begins !!");
if(typeof XLSX === 'undefined' && typeof require !== 'undefined')
XLSX = require('xlsx');
var workbook = XLSX.readFile("Invoice.xlsx", {type: 'base64'});
var first_sheet_name = workbook.SheetNames[0];
var address_of_cell = 'A2';
var worksheet = workbook.Sheets[first_sheet_name];
var desired_cell = worksheet[address_of_cell];
var desired_value = desired_cell.v;
console.log("we got the value as --> "+desired_value);
}
</script>
<button id="btnDoIt" onclick="actionbegins()" name="btnDoIt" class="btn btn-primary">do It !!</button>
</body>
</html>
我試圖尋找一個合適的答案,但找不到任何。請建議。
你正確安裝'xlsx' - 包?它似乎無法找到所需的依賴關係。 –
我簡單地從github下載了這個庫,並在我的HTML中使用它。任何我缺少的東西? –
您是否按照github上的建議安裝了'bower'或'npm'? –