🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

excel-style-dataformatter

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

excel-style-dataformatter

Excel-Style Javascript Data Formatter

1.0.3
Source
npm
Version published
Weekly downloads
1.7K
-12.53%
Maintainers
1
Weekly downloads
 
Created
Source

#Excel-Style Javascript Data Formatter

##Current version supports

  • Number formatting (decimal form, fractional form, percents, etc.)
  • Date formatting (elapsed time, am/pm)
  • Predefined excel formats (Fixed, Standard, etc.)
  • Localization

#Usage

##CommonJS

npm install excel-style-dataformatter
import dataFormatter from 'excel-style-dataformatter';
const result = dataFormatter.format('99', 'Number', 'Currency');

####Creating your own instance

import { DataFormatter } from 'excel-style-dataformatter';
const options = { debug: true };
const dataFormatter = new DataFormatter(options);
const result = dataFormatter.format('123', 'Number', '[Red]0;[Green]0.0');

####Available options

debug {boolean}
locale {string}
transformCode {function}
UTCOffset {number|null} - UTC offset for dates in minutes

##Browser

<!DOCTYPE html>
<html>
<head>
  <script src="dist/excel-style-dataformatter.js"></script>
</head>
<body>
  <script>
    var result = dataFormatter.format('2013-05-22T13:19:59.000','DateTime','yyyy mm dd');
    document.write(result.value);

    // Creating your own instance
    var myDataFormatter = new DataFormatter({ debug: true });
    var myResult = myDataFormatter.format('13.4', 'Number', 'General');
    document.write(myResult.value);
  </script>
</body>
</html>

##AMD

<!DOCTYPE html>
<html>
<head>
  <script src="require.js"></script>
</head>
<body>
  <script>
    require(['dist/excel-style-dataformatter.js'], function() {

      require(['dataFormatter', 'DataFormatter'], function(dataFormatter, DataFormatter) {

        var result = dataFormatter.format('Test', 'String', '[>100][Red]0.0;[>10][Green]-0;[Blue]"Zero";@');
        document.write(result.value);

        // Creating your own instance
        var myDataFormatter = new DataFormatter({ debug: true });
        var myResult = myDataFormatter.format('0', 'Number', 'Yes/No');
        document.write(myResult.value);
      });

    });
  </script>
</body>
</html>

Keywords

excel-like

FAQs

Package last updated on 05 Jul 2016

Did you know?

Socket

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.

Install

Related posts