2 Commits

Author SHA1 Message Date
2b170c9bc0 Fixed export module and add test and clean module and export declare function with props 2021-03-30 13:41:10 +07:00
Sambo Chea
88645b98ea Update README.md 2021-03-30 12:50:19 +07:00
6 changed files with 14 additions and 14 deletions

View File

@@ -27,7 +27,7 @@ excel2json-xlsx -i source.xlsx -o exported.json
``` ```
OR OR
```shell ```shell
npx excel2json -i source.xlsx -o exported.json npx excel2json-xlsx -i source.xlsx -o exported.json
``` ```
# [Docker Hub](https://hub.docker.com/r/cubetiq/excel2json) # [Docker Hub](https://hub.docker.com/r/cubetiq/excel2json)

4
excel2json.d.ts vendored
View File

@@ -1,4 +1,4 @@
interface Excel2JsonProps { export interface Excel2JsonProps {
mappings?: Array<any>; mappings?: Array<any>;
saveToOutput?: boolean; saveToOutput?: boolean;
outputPath?: string; outputPath?: string;
@@ -10,4 +10,4 @@ interface Excel2JsonProps {
encoding?: string; encoding?: string;
} }
declare function excel2json(props: Excel2JsonProps); export declare function excel2json(props: Excel2JsonProps);

View File

@@ -105,7 +105,7 @@ function _internalExport(props = {}) {
console.log("Exported excel to json to output =>", outFile); console.log("Exported excel to json to output =>", outFile);
} catch (err) { } catch (err) {
console.error(err); console.error(err);
} }
} }
return data; return data;
@@ -117,6 +117,6 @@ function _internalExport(props = {}) {
* *
* @returns JSON Object of result * @returns JSON Object of result
*/ */
module.exports = excel2json = (props = {}) => { module.exports.excel2json = excel2json = (props = {}) => {
return _internalExport(props); return _internalExport(props);
}; };

View File

@@ -1,10 +1,5 @@
// import excel2json module // import excel2json module
const excel2json = require("./excel2json"); const { excel2json } = require("./excel2json");
// called function export excel2json // export the function
const exported = excel2json({ module.exports = excel2json;
inputFile: "./data/source.xlsx"
});
// output data from exported
console.log("Output =>\n", exported);

View File

@@ -1,6 +1,6 @@
{ {
"name": "excel2json-xlsx", "name": "excel2json-xlsx",
"version": "1.0.4", "version": "1.0.5",
"keywords": [ "keywords": [
"excel", "excel",
"json", "json",

5
test.js Normal file
View File

@@ -0,0 +1,5 @@
const excel2json = require("./index");
const result = excel2json({
inputFile: "./data/source.xlsx",
});
console.log(result);