-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added sxi (xlsx-import-cli) examples (#129)
- Loading branch information
Showing
12 changed files
with
816 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
./node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Hello | ||
|
||
This is an example how to use `xlsx-import-cli (sxi)` . | ||
|
||
**LIB Version:** `0.0.1-alpha1` | ||
|
||
## Scripts | ||
|
||
* `npm run example:seller` same as `node_modules/.bin/sxi configs/seller.js invoice.xlsx` - imports seller data from invoice.xlsx. | ||
* `npm run example:buyer` same as `node_modules/.bin/sxi configs/buyer.js invoice.xlsx` - imports buyer data from invoice.xlsx. | ||
* `npm run example:items` same as `node_modules/.bin/sxi configs/items.js invoice.xlsx` - imports items data from invoice.xlsx. | ||
* `npm run example:misc` same as `node_modules/.bin/sxi configs/misc.js invoice.xlsx` - imports misc data from invoice.xlsx. | ||
|
||
* `npm run example:all` runs all above at once. | ||
|
||
## What happened | ||
|
||
1. Read spreadsheet file [Invoice.xlsx](invoice.xlsx) | ||
2. Following config import requested data | ||
3. Map and return data. | ||
|
||
## What is worth to see here | ||
|
||
1. Study importer configs: [`./configs/*.js`](configs/) | ||
2. Scripts section in [`package.json`](./package.json) | ||
|
||
## What later | ||
|
||
1. Study documentation: [docs](./../../README.md) | ||
2. Start using **XToolset** in your project | ||
3. Ask a lot, report bugs and request for help: <https://github.com/Siemienik/xtoolset/issues> | ||
4. [Sponsor `xtoolset` project](https://github.com/sponsors/Siemienik) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const cfg = require('./invoiceConfig'); | ||
|
||
module.exports = cfg.getInvoiceConfig().buyer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const getInvoiceConfig = () => ({ | ||
seller: { | ||
worksheet: 'Invoice', | ||
type: 'object', | ||
fields: [ | ||
{ row: 2, col: 1, key: 'name' }, | ||
{ row: 4, col: 2, key: 'taxIdNumber' }, | ||
{ row: 3, col: 1, key: 'address' }, | ||
{ row: 9, col: 4, key: 'accountNo' }, | ||
], | ||
}, | ||
|
||
buyer: { | ||
worksheet: 'Invoice', | ||
type: 'object', | ||
fields: [ | ||
{ row: 2, col: 5, key: 'name' }, | ||
{ row: 4, col: 6, key: 'taxIdNumber' }, | ||
{ row: 3, col: 5, key: 'address' }, | ||
], | ||
}, | ||
|
||
misc: { | ||
worksheet: 'Invoice', | ||
type: 'object', | ||
fields: [ | ||
{ row: 6, col: 5, key: 'date', mapper: v => new Date(v) }, //todo mapper | ||
{ row: 7, col: 5, key: 'dueDate', mapper: v => new Date(v) }, //todo mapper | ||
], | ||
}, | ||
|
||
items: { | ||
worksheet: 'Invoice', | ||
type: 'list', | ||
rowOffset: 13, | ||
columns: [ | ||
{ index: 2, key: 'item' }, | ||
{ index: 4, key: 'unitPrice', mapper: v => Number(v) }, | ||
{ index: 5, key: 'quantity', mapper: v => Number(v) }, | ||
{ index: 6, key: 'price', mapper: v => Number(v) }, | ||
], | ||
}, | ||
}); | ||
|
||
module.exports = { getInvoiceConfig }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const cfg = require('./invoiceConfig'); | ||
|
||
module.exports = cfg.getInvoiceConfig().items; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const cfg = require('./invoiceConfig'); | ||
|
||
module.exports = cfg.getInvoiceConfig().misc; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const cfg = require('./invoiceConfig'); | ||
|
||
module.exports = cfg.getInvoiceConfig().seller; |
Binary file not shown.
Oops, something went wrong.