Universal JavaScript/TypeScript library for importing and exporting tabular data.
Supports browser and Node.js environments and provides a unified API for converting spreadsheets, JSON data, and tabular documents.
Used in Unsonet projects, including the Excelsior extension.
On the Excelsior PDF demo page, data is exported via the excelsior-data-converter.
Try it in action: DEMO
- Import spreadsheets and JSON files into structured data
- Export structured data to multiple formats
- XLSX / XLS support
- CSV / TSV support
- PDF, DOCX, images and other export formats
- Browser support
- Node.js support
- TypeScript support
- Command-line interface
- Client-side processing
- No server required
- No AI dependencies
- No OCR dependencies
npm install @unsonet/excelsior-data-converteror
pnpm add @unsonet/excelsior-data-converterThe ImportService converts files represented as FileItem-like objects into structured JavaScript data.
import { ImportService } from '@unsonet/excelsior-data-converter';
const service = new ImportService();
const result = service.convertFileItemToData({
name: 'employees.xlsx',
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
size: file.size,
base64
});
console.log(result);The base64 property can contain either a raw Base64 string or a Data URL.
By default, nested spreadsheet column names can be converted into nested objects.
Use flatStructure: true to keep the original flat structure:
const result = service.convertFileItemToData(
{
name: 'employees.xlsx',
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
size: file.size,
base64
},
{
flatStructure: true
}
);Use ExportService.download() to export an array of objects.
import { ExportService } from '@unsonet/excelsior-data-converter';
const service = new ExportService();
const data = [
{
id: 1,
name: 'John'
},
{
id: 2,
name: 'Alice'
}
];
await service.download(data, 'employees', 'xlsx');The arguments are:
service.download(
data,
fileName,
extension
);For example:
await service.download(data, 'employees', 'csv');or:
await service.download(data, 'employees', 'pdf');The export process is performed locally without sending data to a server.
ExportService also provides methods for converting HTML content into different formats.
For example:
const service = new ExportService();
await service.save(
{
type: 'pdf',
elementIdOrContent: 'my-table'
},
'employees'
).toPromise();The elementIdOrContent property can contain either an element ID or an HTMLElement.
The package includes a command-line interface for importing and exporting files.
After global installation:
npm install -g @unsonet/excelsior-data-converteryou can use:
excelsior-data-converterConvert a supported input file into JSON:
excelsior-data-converter import <file>Example:
excelsior-data-converter import employees.xlsxSave the result to a file:
excelsior-data-converter import employees.xlsx -o result.jsonPretty formatted JSON:
excelsior-data-converter import employees.xlsx --prettyFlat structure:
excelsior-data-converter import employees.xlsx --flatConvert a JSON file into another supported format:
excelsior-data-converter export <file> --to <extension>Example:
excelsior-data-converter export employees.json --to xlsxExport to CSV:
excelsior-data-converter export employees.json --to csvSpecify the output file:
excelsior-data-converter export employees.json --to xlsx -o result.xlsxSpecify the output name:
excelsior-data-converter export employees.json --to xlsx -n employees| Option | Description |
|---|---|
-o, --output |
Output JSON file |
-f, --flat |
Keep a flat data structure |
-p, --pretty |
Pretty-print JSON |
-e, --encoding |
Input file encoding |
-s, --silent |
Suppress progress messages |
| Option | Description |
|---|---|
-t, --to |
Target format |
-o, --output |
Output file |
-n, --name |
Output file name |
-s, --silent |
Suppress progress messages |
The import service currently handles:
- XLSX
- XLSM
- XLSB
- XLS
- XLA
- XLAM
- CSV
- JSON
Other formats may be handled as JSON depending on the input data.
The export service supports a wide range of formats, including:
- XLSX
- XLSM
- XLSB
- XLS
- XLA
- XLAM
- Numbers
- ODS
- FODS
- WK1
- WK3
- BIFF2
- BIFF3
- BIFF4
- BIFF5
- CSV
- TSV
- TXT
- HTML
- RTF
- PRN
- SYLK
- DIF
- DBF
- ETH
- DOCX
- DOC
- PNG
- JPEG
- BMP
- GIF
- TIFF
- SVG
- XML
- JSON
import {
ImportService,
ExportService
} from '@unsonet/excelsior-data-converter';
const importer = new ImportService();
const exporter = new ExportService();The library is designed to work in modern browsers and can be used in browser applications and browser extensions.
All browser-side processing is performed locally.
import {
ImportService,
ExportService
} from '@unsonet/excelsior-data-converter';
const importer = new ImportService();
const exporter = new ExportService();Node.js 18+ is recommended.
The package also provides a command-line interface for Node.js.
The package includes TypeScript declarations.
import { ExportService } from '@unsonet/excelsior-data-converter';
const service = new ExportService();
await service.download(
[
{ id: 1, name: 'John' },
{ id: 2, name: 'Alice' }
],
'employees',
'xlsx'
);No additional type definitions are required.
Excelsior Data Converter can be used for:
- Browser extensions
- Data migration
- ETL workflows
- Spreadsheet processing
- Client-side data conversion
- Server-side data conversion
- Exporting application data
- Converting spreadsheet data to JSON
- Converting JSON data to spreadsheet formats
The library does not provide:
- OCR
- Scanned document recognition
- Image-based table extraction
- AI-assisted data extraction
MIT