
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
ssr-xlsx-export
Advanced tools
A lightweight library to convert array data to downloadable XLSX files
A lightweight, TypeScript-compatible npm library for converting array data to downloadable XLSX (Excel) files in the browser.
🌐 Browser-Only Library: This library is designed specifically for frontend applications and requires a browser environment to function. It will not work in Node.js, server-side rendering, or backend environments.
npm install ssr-xlsx-export
Check out the interactive demo here:
👉 Live Demo on CodeSandbox
import { ArrayToXLSX } from "ssr-xlsx-export";
document.getElementById("download-report").addEventListener("click", () => {
const reportData = [
{ name: "John Doe", age: 30, city: "New York" },
{ name: "Jane Smith", age: 25, city: "Los Angeles" },
{ name: "Bob Johnson", age: 35, city: "Chicago" },
];
ArrayToXLSX(reportData, {
filename: "styled-report",
sheetName: "Styled Sheet",
headers: ["Name", "Age", "City"],
headerStyle: {
font: { bold: true, color: { rgb: "FF0000" } },
alignment: { horizontal: "center" },
},
});
});
headerStyleYou can customize header cells using the headerStyle property:
headerStyle: {
font: { bold: true, color: { rgb: "FF0000" } },
alignment: { horizontal: "center" },
}
import { ArrayToXLSX, ArrayData, DownloadOptions } from "ssr-xlsx-export";
interface User {
name: string;
age: number;
city: string;
}
const handleDownload = (data: User[]) => {
const options: DownloadOptions = {
filename: "user-report",
sheetName: "Users",
headers: ["Full Name", "Age", "City"],
includeHeaders: true,
};
ArrayToXLSX(data, options);
};
import React, { useState } from "react";
import { ArrayToXLSX, createHeaderStyle } from "ssr-xlsx-export";
const ReportComponent = () => {
const [reportData, setReportData] = useState([]);
const handleDownloadReport = () => {
// Your data fetching logic here
const data = [
{ product: "Laptop", sales: 150, revenue: 75000 },
{ product: "Phone", sales: 300, revenue: 60000 },
{ product: "Tablet", sales: 200, revenue: 40000 },
];
const headerStyle = createHeaderStyle("#4472C4", "#FFFFFF", true, 14);
ArrayToXLSX(data, {
filename: "sales-report",
sheetName: "Q1 Sales",
headers: ["Product Name", "Units Sold", "Total Revenue"],
headerStyle,
});
};
return <button onClick={handleDownloadReport}>Download Sales Report</button>;
};
export default ReportComponent;
<template>
<button @click="downloadReport">Download Report</button>
</template>
<script>
import { ArrayToXLSX } from "ssr-xlsx-export";
export default {
methods: {
downloadReport() {
const data = [
{ name: "Alice", score: 95, grade: "A" },
{ name: "Bob", score: 87, grade: "B" },
{ name: "Charlie", score: 92, grade: "A" },
];
ArrayToXLSX(data, {
filename: "student-grades",
sheetName: "Grades",
});
},
},
};
</script>
import { ArrayToXLSX } from "ssr-xlsx-export";
const matrixData = [
["Product", "Q1", "Q2", "Q3", "Q4"],
["Laptops", 120, 130, 140, 150],
["Phones", 200, 220, 210, 230],
["Tablets", 80, 90, 85, 95],
];
ArrayToXLSX(matrixData, {
filename: "quarterly-sales",
includeHeaders: false, // First row is already headers
});
ArrayToXLSX(data, options)Main function to convert array data to downloadable XLSX file.
data: ArrayData - Array of objects or array of arraysoptions: DownloadOptions - Configuration options (optional)interface DownloadOptions {
filename?: string; // Default: 'report'
sheetName?: string; // Default: 'Sheet1'
headers?: string[]; // Custom column headers
includeHeaders?: boolean; // Default: true
}
validateArrayData(data: any): booleanValidates if the provided data is in the correct format for conversion.
import { validateArrayData } from "ssr-xlsx-export";
const data = [{ name: "John", age: 30 }];
if (validateArrayData(data)) {
console.log("Data is valid for XLSX conversion");
}
csvToArray(csvString: string, delimiter?: string): string[][]Converts a CSV string to array format suitable for XLSX conversion.
import { csvToArray, ArrayToXLSX } from "ssr-xlsx-export";
const csvData = `Name,Age,City
John Doe,30,New York
Jane Smith,25,Los Angeles`;
const arrayData = csvToArray(csvData);
ArrayToXLSX(arrayData, {
filename: "csv-converted-data",
});
[
{ name: "John", age: 30, city: "NYC" },
{ name: "Jane", age: 25, city: "LA" },
];
[
["Name", "Age", "City"],
["John", 30, "NYC"],
["Jane", 25, "LA"],
];
The library includes comprehensive error handling:
try {
ArrayToXLSX(data, options);
console.log("Download initiated successfully!");
} catch (error) {
console.error("Download failed:", error.message);
// Handle specific error cases
if (error.message.includes("browser environment")) {
alert("This feature only works in web browsers");
}
}
Common errors:
This library works in all modern browsers that support:
xlsx: For Excel file generation and manipulation# Install the package
npm install ssr-xlsx-export
# For TypeScript projects, types are included
# No need for @types/ssr-xlsx-export
This error occurs when trying to use the library in a Node.js environment. The library is designed for frontend use only.
Solution: Use this library only in client-side code (React components, Vue components, vanilla JS in browsers).
Ensure your browser supports the Blob API and file downloads. Some corporate firewalls or browser extensions might block automatic downloads.
For very large datasets (10,000+ rows), consider:
# Clone the repository
git clone https://github.com/SriRakeshKumar/ssr-xlsx-export.git
# Install dependencies
npm install
# Build the library
npm run build
# Run tests
npm test
MIT License - see LICENSE file for details.
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)If you encounter any issues or have questions:
Note: This is a client-side library designed for browser environments. For server-side Excel generation in Node.js, consider using libraries like exceljs or xlsx directly with file system operations.
FAQs
A lightweight library to convert array data to downloadable XLSX files
We found that ssr-xlsx-export demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.