csf-utils
v1.2.0
Published
Common Spreadsheet Format utilities
Downloads
10
Maintainers
Readme
Common Spreadsheet Format utilities
Contains:
Install
npm install csf-utils
API
parseCell(cell)
cell
Required
Type: string | object
var csfUtils = require('csf-utils');
csfUtils.parseCell('A1'); // { row: 1, column: 1 }
csfUtils.parseCell({ row: 1, column: 1 }); // A1
columnName.intToExcelCol(column)
column
Required
Type: number
var csfUtils = require('csf-utils');
csfUtils.columnName.intToExcelCol(1); // 'A'
columnName.excelColToInt(column)
column
Required
Type: string
var csfUtils = require('csf-utils');
csfUtils.columnName.excelColToInt('A'); // 1
convert.sheetToAoa(data)
data
Required
Type: object
var csfUtils = require('csf-utils');
var sheetData = {
A1: { t: 's', v: 'A1' },
C1: { t: 's', v: 'C1' },
D1: { t: 's', v: 'D1' },
E1: { t: 's', v: 'E1' },
A2: { t: 's', v: 'A2' },
B2: { t: 's', v: 'B2' },
C2: { t: 's', v: 'C2' },
E2: { t: 's', v: 'E2' },
'!ref': 'A1:E2',
};
var aoa = csfUtils.convert.sheetToAoa(sheetData);
/* result:
[
[
{ t: 's', v: 'A1' },
undefined,
{ t: 's', v: 'C1' },
{ t: 's', v: 'D1' },
{ t: 's', v: 'E1' } ],
[
{ t: 's', v: 'A2' },
{ t: 's', v: 'B2' },
{ t: 's', v: 'C2' },
undefined,
{ t: 's', v: 'E2' }
]
]
*/
convert.aoaToSheet(data)
data
Required
Type: Array
var csfUtils = require('csf-utils');
var aoa = [
[
{ t: 's', v: 'A1' },
undefined,
{ t: 's', v: 'C1' },
{ t: 's', v: 'D1' },
{ t: 's', v: 'E1' } ],
[
{ t: 's', v: 'A2' },
{ t: 's', v: 'B2' },
{ t: 's', v: 'C2' },
undefined,
{ t: 's', v: 'E2' }
]
]
var sheetData = csfUtils.convert.aoaToSheet(sheetData);
/* result:
{
A1: { t: 's', v: 'A1' },
C1: { t: 's', v: 'C1' },
D1: { t: 's', v: 'D1' },
E1: { t: 's', v: 'E1' },
A2: { t: 's', v: 'A2' },
B2: { t: 's', v: 'B2' },
C2: { t: 's', v: 'C2' },
E2: { t: 's', v: 'E2' },
'!ref': 'A1:E2',
}
*/