Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
am-xlsx2json
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Aksimaya
am-xlsx2json
Commits
14af61cd
Commit
14af61cd
authored
Nov 12, 2015
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support multi sheet selected
parent
a3d79e61
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
10 deletions
+22
-10
example.js
example/example.js
+2
-1
output.json
example/output.json
+1
-1
place-sample.xls
example/place-sample.xls
+0
-0
index.js
lib/index.js
+19
-8
No files found.
example/example.js
View file @
14af61cd
...
...
@@ -2,7 +2,8 @@ var am_xlsx2json = require('../')
am_xlsx2json
({
input
:
__dirname
+
'
/place-sample.xls
'
,
output
:
__dirname
+
'
/output.json
'
output
:
__dirname
+
'
/output.json
'
,
sheet
:[
'
Worksheet
'
,
'
Sheet1
'
]
},
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
...
...
example/output.json
View file @
14af61cd
This diff is collapsed.
Click to expand it.
example/place-sample.xls
View file @
14af61cd
No preview for this file type
lib/index.js
View file @
14af61cd
...
...
@@ -23,7 +23,7 @@ function XLSX_json(config, callback) {
function
CV
(
config
,
callback
)
{
var
wb
=
this
.
load_xlsx
(
config
.
input
)
var
json
=
this
.
to_json
(
wb
);
var
json
=
this
.
to_json
(
wb
,
config
);
var
output
=
config
.
output
;
if
(
config
.
output
!==
null
)
{
var
stream
=
fs
.
createWriteStream
(
output
,
{
...
...
@@ -39,13 +39,24 @@ function CV(config, callback) {
CV
.
prototype
.
load_xlsx
=
function
(
input
)
{
return
xlsx
.
readFile
(
input
);
}
CV
.
prototype
.
to_json
=
function
(
workbook
)
{
CV
.
prototype
.
to_json
=
function
(
workbook
,
config
)
{
var
result
=
{};
workbook
.
SheetNames
.
forEach
(
function
(
sheetName
)
{
var
roa
=
xlsx
.
utils
.
sheet_to_row_object_array
(
workbook
.
Sheets
[
sheetName
]);
if
(
roa
.
length
>
0
){
result
[
sheetName
]
=
roa
;
}
});
var
target_sheet
=
config
.
sheet
;
if
(
target_sheet
==
null
){
workbook
.
SheetNames
.
forEach
(
function
(
sheetName
)
{
var
roa
=
xlsx
.
utils
.
sheet_to_row_object_array
(
workbook
.
Sheets
[
sheetName
]);
if
(
roa
.
length
>
0
){
result
[
sheetName
]
=
roa
;
}
});
}
else
{
target_sheet
.
forEach
(
function
(
sheetName
)
{
var
roa
=
xlsx
.
utils
.
sheet_to_row_object_array
(
workbook
.
Sheets
[
sheetName
]);
if
(
roa
.
length
>
0
){
result
[
sheetName
]
=
roa
;
}
})
}
return
result
;
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment