@dipti_yelve/xlsx-helper
v2.0.0
Published
A simple JavaScript library to convert **JSON to XLSX** files and **XLSX to JSON** with ease. Perfect for Node.js projects where you need quick Excel file handling.
Readme
📦 xlsx-helper
A simple JavaScript library to convert JSON to XLSX files and XLSX to JSON with ease.
Perfect for Node.js projects where you need quick Excel file handling.
⚙️ Requirements
- Node.js
>=14 - npm
>=6
🚀 Installation
npm install @dipti_yelve/xlsx-helper📖 Usage
Import the library
const { jsonToXlsx, xlsxToJson } = require("@dipti_yelve/xlsx-helper");Convert JSON → XLSX
(async () => {
// Provide .JSON file path and path to save the converted .xlsx file in params
await ExcelConverter.jsonToXlsx("data.json", "output.xlsx");
console.log("✅ XLSX file created");
})();Convert XLSX → JSON
(async () => {
// Provide .xlsx file path that you want to be converted into .JSON file in params
await ExcelConverter.xlsxToJson("output.xlsx");
console.log("✅ XLSX file created");
})();📂 Example
data.json(input file):
[
{
"name": "Employees",
"properties": {
"defaultRowHeight": 15,
"dyDescent": 55,
"outlineLevelRow": 0,
"outlineLevelCol": 0,
"tabColor": {
"argb": "FFC0000"
}
},
"rows": [
{
"number": 1,
"height": 25,
"cells": [
{
"address": "A1",
"value": "Name",
"type": 3,
"style": {
"font": {
"bold": true
},
"border": {},
"fill": {
"type": "pattern",
"pattern": "none"
}
}
},
{
"address": "B1",
"value": "Age",
"type": 3,
"style": {
"font": {
"bold": true
},
"border": {},
"fill": {
"type": "pattern",
"pattern": "none"
}
}
},
{
"address": "C1",
"value": "City",
"type": 3,
"style": {
"font": {
"bold": true
},
"border": {},
"fill": {
"type": "pattern",
"pattern": "none"
}
}
}
]
},
{
"number": 2,
"height": 20,
"cells": [
{
"address": "A2",
"value": "Alice",
"type": 3,
"style": {}
},
{
"address": "B2",
"value": 25,
"type": 2,
"style": {}
},
{
"address": "C2",
"value": "Pune",
"type": 3,
"style": {}
}
]
}
],
"merges": {},
"dataValidations": [],
"columns": [
{
"width": 5
},
{
"width": 5
},
{
"width": 5
}
]
}
]✨ Features
- Simple API for converting JSON ↔ XLSX
- Works with Node.js
- Async/await friendly
✨ Author
Dipti Yelve
- GitHub: @DiptiYelve
- npm: @dipti_yelve/xlsx-helper
