mirror of
https://github.com/nocodb/nocodb.git
synced 2026-04-30 15:16:44 +00:00
test(cypress): excel import validation (draft/wip)
Signed-off-by: Raju Udava <sivadstala@gmail.com>
This commit is contained in:
23
scripts/cypress/plugins/read-xlsx.js
Normal file
23
scripts/cypress/plugins/read-xlsx.js
Normal file
@@ -0,0 +1,23 @@
|
||||
// https://stackoverflow.com/questions/61934443/read-excel-files-in-cypress
|
||||
|
||||
const fs = require('fs');
|
||||
const XLSX = require('xlsx');
|
||||
|
||||
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]);
|
||||
return rows
|
||||
}
|
||||
|
||||
const sheetList = ({file}) => {
|
||||
const buf = fs.readFileSync(file);
|
||||
const workbook = XLSX.read(buf, { type: 'buffer' });
|
||||
const rows = workbook.SheetNames
|
||||
return rows
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
read,
|
||||
sheetList,
|
||||
}
|
||||
Reference in New Issue
Block a user