mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
882 B
34 lines
882 B
3 years ago
|
// https://stackoverflow.com/questions/61934443/read-excel-files-in-cypress
|
||
|
|
||
3 years ago
|
const fs = require("fs");
|
||
|
const XLSX = require("xlsx");
|
||
3 years ago
|
|
||
3 years ago
|
const read = ({ file, sheet }) => {
|
||
2 years ago
|
const buf = fs.readFileSync(file);
|
||
|
const workbook = XLSX.read(buf, { type: "buffer" });
|
||
|
const rows = XLSX.utils.sheet_to_json(workbook.Sheets[sheet]);
|
||
|
return rows;
|
||
3 years ago
|
};
|
||
3 years ago
|
|
||
3 years ago
|
// const read = ({file, sheet}) => {
|
||
|
// const buf = fs.readFileSync(file);
|
||
|
// const workbook = XLSX.read(buf, { type: 'buffer' });
|
||
|
// const rows = XLSX.utils.sheet_to_json(workbook.Sheets[sheet], {
|
||
|
// header: 1,
|
||
|
// blankrows: false
|
||
|
// });
|
||
|
// return rows
|
||
|
// }
|
||
|
|
||
3 years ago
|
const sheetList = ({ file }) => {
|
||
2 years ago
|
const buf = fs.readFileSync(file);
|
||
|
const workbook = XLSX.read(buf, { type: "buffer" });
|
||
|
const rows = workbook.SheetNames;
|
||
|
return rows;
|
||
3 years ago
|
};
|
||
3 years ago
|
|
||
|
module.exports = {
|
||
2 years ago
|
read,
|
||
|
sheetList,
|
||
3 years ago
|
};
|