Nowdays everything is easly maintain if we are dealing with objects .As I have face many problems while in uploading excel file ,taking data from excel and play with each Cell of excel file .This Converter is just a interface which helps to get objects from excel Or excel from objects.
link https://github.com/hardy12994/xlconverter
Here are the two Converters and Some Getters (define below) present in it :
- Excel to Objects
- Objects to Excel
Excel to Objects
let xlconverter = require; let path="abv/cac/ac/ac.xlsx"; let sheet="sheet1"; // xlToObjects, will provide objects of all the sheets present in xl sheet; xlconverter.xlToObjects
Objects to Excel
let headers=["name","age"]; let rows=[{ name:"hardy",age:21 },{ name:"hardy",age:21 }]; let path="abc/cac/"; let fileName="myNewSheet"; //.xlsx is by default let sheetName="sheet1"; xlconverter.objectsToXl
Getters
We can use Excel Sheet as a very small Database as we can do Extractions from that by putting some queries, The query can be made in form of Objects, Arrays Thing can be achive like:
- Any Perticular Row.
- Any Perticular Column.
- Get Number of Rows.
- Get Number of Columns.
- Get Data as Objects of Perticular Columns.
Get Row
- Accept Query as Object Eg-
{name:"Jhon",age:"21"}
. and
type of query will be done.- Return Single Row which matches both Conditions
First
.
let rowQuery= {name:"Jhon",age:"21"}; let filePath="abc/cac/"; let sheetName="sheet1"; xlconverter.getters.row
Get Rows
- Accept Parameters as Object Eg-
{name:"Jhon",age:"21"}
. and
type of query will be done.- Return Multiple Rows which matches both Conditions.
let rowQuery= {name:"Jhon",age:"21"}; let filePath="abc/cac/"; let sheetName="sheet1"; xlconverter.getters.rows
Get Column
- Accept Parameters as String Eg-
"name"
. - Return Array of Strings which is Present in that Column.
let colQuery= "name"; let filePath="abc/cac/"; let sheetName="sheet1"; xlconverter.getters.coloumn
Get Columns
- Accept Parameters as String in Array Eg-
["name","age"]
. - Return Object with Keys name and age and both of them have Array of Strings which is Present in respective Column.
let colQuery= ["name","age"]; let filePath="abc/cac/"; let sheetName="sheet1"; xlconverter.getters.coloumns
Get Rows from Selective Columns
- Accept Parameters as String in Array Eg-
["name","age"]
. - Return all Rows with Selected Columns name and age as Objects in Array
- Getting Selective Coloumns of Rows.
let colQuery= ["name","age"]; let filePath="abc/cac/"; let sheetName="sheet1"; xlconverter.getters.selectiveColoumnsOfRows
N O T E :
callback
function is required in all methods.getters
are usingxlToObjectsOfSheet
function that's why sheet name is required.
Contributions are most wellcome