
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
@tarunbatta/excelexportjs
Advanced tools
A lightweight JavaScript library for exporting data to Excel files directly in the browser. No server-side processing required.
npm install excelexportjs
import { ExcelExport, Table, CellType, HorizontalAlignment, VerticalAlignment } from 'excelexportjs';
// Create a table definition
const table: Table = {
name: 'Sales Report',
columns: [
{
headerText: 'Account Number',
name: 'accountNumber',
// Use LargeNumber type to prevent scientific notation for large numbers
type: { cellType: CellType.LargeNumber, format: '@' },
width: 150,
isVisible: true,
style: {
fontFamily: 'Arial',
fontSize: 12,
fontColor: '#000000',
isBold: false, // Text is not bold by default
isItalic: false,
isUnderline: false,
backgroundColor: '#FFFFFF',
horizontalAlignment: HorizontalAlignment.Left,
verticalAlignment: VerticalAlignment.Center,
isWrapped: false,
isMerged: false,
rowSpan: 1,
columnSpan: 1
}
},
{
headerText: 'Sales',
name: 'sales',
type: { cellType: CellType.Number, format: '$#,##0.00' },
width: 100,
isVisible: true,
style: {
fontFamily: 'Arial',
fontSize: 12,
fontColor: '#000000',
isBold: false,
isItalic: false,
isUnderline: false,
backgroundColor: '#FFFFFF',
horizontalAlignment: HorizontalAlignment.Right,
verticalAlignment: VerticalAlignment.Center,
isWrapped: false,
isMerged: false,
rowSpan: 1,
columnSpan: 1
}
},
{
headerText: 'Hidden Column',
name: 'hidden',
type: { cellType: CellType.String, format: '@' },
width: 100,
isVisible: false, // This column will be hidden in Excel
style: new DefaultCellStyle()
}
],
rows: [
{ items: ['010400592144000101', 1500.50, 'hidden data'] },
{ items: ['010400592144000102', 2750.75, 'hidden data'] }
],
headerStyle: {
fontFamily: 'Arial',
fontSize: 12,
fontColor: '#000000',
isBold: true, // Only headers are bold by default
isItalic: false,
isUnderline: false,
backgroundColor: '#FFFFFF',
horizontalAlignment: HorizontalAlignment.Center,
verticalAlignment: VerticalAlignment.Center,
isWrapped: false,
isMerged: false,
rowSpan: 1,
columnSpan: 1
},
defaultColumnWidth: null,
defaultRowWidth: null
};
// Create and export Excel file with dynamic name
const date = new Date().toISOString().split('T')[0];
const excelExport = new ExcelExport([table], `SalesReport_${date}`);
excelExport.createExcel();
Main class for creating Excel exports.
new ExcelExport(
dataSet: Table[],
fileName?: string, // Custom name for the Excel file (default: 'ExcelExport')
author?: string,
company?: string,
version?: string,
style?: CellStyle
)
dataSet: Array of tables to exportfileName: Name of the Excel file (default: 'ExcelExport')author: Author name (default: 'ExcelExportJS')company: Company name (default: 'ExcelExportJS')version: Version number (default: '1.0.0')style: Default cell style (default: new DefaultCellStyle())createExcel(returnUrl: boolean = false): string | Blob
returnUrl is true, returns a blob URL instead of downloadingRepresents a worksheet in the Excel file.
interface Table {
name: string;
columns: Column[];
rows: Row[];
headerStyle: CellStyle;
defaultColumnWidth: number | null;
defaultRowWidth: number | null;
}
Defines a column in the Excel file.
interface Column {
headerText: string;
name: string;
type: ColumnType;
width: number;
isVisible: boolean; // Controls column visibility in Excel
style: CellStyle;
}
Defines the style properties for cells.
interface CellStyle {
fontFamily: string;
fontSize: number;
fontColor: string;
isBold: boolean; // Controls text boldness
isItalic: boolean;
isUnderline: boolean;
backgroundColor: string;
horizontalAlignment: HorizontalAlignment;
verticalAlignment: VerticalAlignment;
isWrapped: boolean;
isMerged: boolean;
rowSpan: number;
columnSpan: number;
}
CellType.String: Text dataCellType.Number: Numeric dataCellType.Date: Date/time dataCellType.Boolean: Boolean valuesCellType.LargeNumber: Large numbers that should be treated as text to prevent scientific notation (e.g., account numbers, IDs)CellType.Float: Floating-point numbersCellType.Percent: Percentage valuesCellType.Html: HTML contentLarge Numbers: Use CellType.LargeNumber for any numeric values that should not be displayed in scientific notation (e.g., account numbers, IDs, etc.)
type: { cellType: CellType.LargeNumber, format: '@' }
Hidden Columns: Set isVisible: false for any columns that should not appear in the Excel file
isVisible: false
Text Styling: By default, text is not bold. Only headers are bold by default. Override isBold in the style if needed
style: {
...new DefaultCellStyle(),
isBold: false // Explicitly set to false for non-bold text
}
Dynamic File Names: Use the fileName parameter to create dynamic file names
const date = new Date().toISOString().split('T')[0];
new ExcelExport([table], `Report_${date}`);
LeftCenterRightTopCenterBottomContributions are welcome! Please feel free to submit a Pull Request.
MIT © BattaTech
If you find this package helpful, please consider giving it a ⭐️ on GitHub!
FAQs
Client Side Excel Export using TypeScript
We found that @tarunbatta/excelexportjs 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.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.