Registry / productivity / excel-style-dataformatter

excel-style-dataformatter

JSON →
library2.0.1jsnpmunverified

A JavaScript library that formats data (numbers, dates, etc.) in Excel-like styles. Current stable version is 2.0.1. It provides number formatting (decimal, fractional, percent), date formatting (elapsed time, AM/PM), predefined Excel formats, and localization support. The library is lightweight, supports CommonJS, AMD, and browser environments, and allows custom locale definitions and UTC offsets.

npm install excel-style-dataformatter
INSTALL
IMPORT
SIG · EXCEL-STYLE-DATAFO
E
excel-style-dataformatter
productivityjavascriptv2.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DataFormatter
import DataFormatter from 'excel-style-dataformatter'
const DataFormatter = require('excel-style-dataformatter')
Default export. In CommonJS, use require but note default import behavior. The library is ESM-first.
DataFormatter
import DataFormatter from 'excel-style-dataformatter'
import { DataFormatter } from 'excel-style-dataformatter'
It's a default export, not a named export.
locales
import ru from 'excel-style-dataformatter/lib/ru'
import ru from 'excel-style-dataformatter/locales/ru'
Locale files are under lib/ directory.

Initializes DataFormatter with Russian locale, formats a number as currency, and logs the result.

import DataFormatter from 'excel-style-dataformatter'; import ru from 'excel-style-dataformatter/lib/ru'; const df = new DataFormatter({ locales: [ru] }); df.setLocale('ru'); const result = df.format('99', 'Number', 'Currency'); console.log(result.value); // '99,00 ₽'
Debug
Known issues
gotchaThe format() method expects value as string, not number. Passing a number may cause unexpected behavior.
fix
Convert numbers to string: dataFormatter.format(String(99), 'Number', 'Currency')
affects: >=1.0.0
breakingVersion 2.0.0 changed the import path for locales from 'excel-style-dataformatter/locales/...' to 'excel-style-dataformatter/lib/...'.
fix
Update imports: `import ru from 'excel-style-dataformatter/lib/ru'`
affects: >=2.0.0
deprecatedThe option 'UTCOffset' is deprecated in favor of setUTCOffset method.
fix
Use `dataFormatter.setUTCOffset(offset)` instead of passing UTCOffset in constructor.
affects: >=1.1.0
gotchaWhen using in a browser with a script tag, the global variable is `window.DataFormatter`, but locales are under `window.DataFormatter_ru`.
fix
Access the global correctly: `new window.DataFormatter({ locales: [window.DataFormatter_ru] })`
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: DataFormatter is not a constructor
Using named import instead of default import.
fix
Use `import DataFormatter from 'excel-style-dataformatter'` instead of `import { DataFormatter } from 'excel-style-dataformatter'`
Cannot find module 'excel-style-dataformatter/locales/ru'
Incorrect import path for locales (path changed in v2).
fix
Use `import ru from 'excel-style-dataformatter/lib/ru'`
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
26 hits · last 30 days
node
24
OpenAI (training)
1
Resources
excel-style-dataformatter — npm install excel-style-dataformatter · libregistry