Skip to content

About

Data conversion engine.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Excelsior Data Converter

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.


Demo

On the Excelsior PDF demo page, data is exported via the excelsior-data-converter.

Try it in action: DEMO


Features

  • 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

Installation

npm install @unsonet/excelsior-data-converter

or

pnpm add @unsonet/excelsior-data-converter

Importing Data

The 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.

Flat Structure

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
  }
);

Exporting Data

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.


Exporting from HTML

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.


CLI Usage

The package includes a command-line interface for importing and exporting files.

After global installation:

npm install -g @unsonet/excelsior-data-converter

you can use:

excelsior-data-converter

CLI Commands

Import File to JSON

Convert a supported input file into JSON:

excelsior-data-converter import <file>

Example:

excelsior-data-converter import employees.xlsx

Save the result to a file:

excelsior-data-converter import employees.xlsx -o result.json

Pretty formatted JSON:

excelsior-data-converter import employees.xlsx --pretty

Flat structure:

excelsior-data-converter import employees.xlsx --flat

Export JSON

Convert a JSON file into another supported format:

excelsior-data-converter export <file> --to <extension>

Example:

excelsior-data-converter export employees.json --to xlsx

Export to CSV:

excelsior-data-converter export employees.json --to csv

Specify the output file:

excelsior-data-converter export employees.json --to xlsx -o result.xlsx

Specify the output name:

excelsior-data-converter export employees.json --to xlsx -n employees

CLI Options

Import Options

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

Export Options

Option Description
-t, --to Target format
-o, --output Output file
-n, --name Output file name
-s, --silent Suppress progress messages

Supported Formats

Import

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.


Export

The export service supports a wide range of formats, including:

Spreadsheet formats

  • XLSX
  • XLSM
  • XLSB
  • XLS
  • XLA
  • XLAM
  • Numbers
  • ODS
  • FODS
  • WK1
  • WK3
  • BIFF2
  • BIFF3
  • BIFF4
  • BIFF5

Text and tabular formats

  • CSV
  • TSV
  • TXT
  • HTML
  • RTF
  • PRN
  • SYLK
  • DIF
  • DBF
  • ETH

Documents

  • PDF
  • DOCX
  • DOC

Images

  • PNG
  • JPEG
  • BMP
  • GIF
  • TIFF

Other formats

  • SVG
  • XML
  • JSON

Browser Usage

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.


Node.js Usage

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.


TypeScript

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.


Use Cases

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

Limitations

The library does not provide:

  • OCR
  • Scanned document recognition
  • Image-based table extraction
  • AI-assisted data extraction

License

MIT

About

Data conversion engine.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages