Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
UGL
website
Commits
7ee3266a
Commit
7ee3266a
authored
Apr 19, 2021
by
Sini
Browse files
xlsx to json conversion with console output
parent
b84325cd
Changes
1
Hide whitespace changes
Inline
Side-by-side
public/js/search.js
View file @
7ee3266a
...
...
@@ -59,6 +59,55 @@ var stuff_paper = []
// }
// // stuff.forEach(addcontent());
// });
//
// begining of xlsx to json coversion
//
/* set up XMLHttpRequest */
var
url
=
"
./content/CitationSheet.xlsx
"
;
var
xmlHttpRequest
=
new
XMLHttpRequest
();
xmlHttpRequest
.
open
(
"
GET
"
,
url
,
true
);
xmlHttpRequest
.
responseType
=
"
arraybuffer
"
;
xmlHttpRequest
.
onload
=
function
(
e
)
{
var
arraybuffer
=
xmlHttpRequest
.
response
;
/* convert data to binary string */
var
data
=
new
Uint8Array
(
arraybuffer
);
var
arr
=
new
Array
();
for
(
var
i
=
0
;
i
!=
data
.
length
;
++
i
)
arr
[
i
]
=
String
.
fromCharCode
(
data
[
i
]);
var
bstr
=
arr
.
join
(
""
);
/* Call XLSX */
var
workbook
=
XLSX
.
read
(
bstr
,
{
type
:
"
binary
"
});
/* DO SOMETHING WITH workbook HERE */
var
first_sheet_name
=
workbook
.
SheetNames
[
0
];
/* Get worksheet */
var
worksheet
=
workbook
.
Sheets
[
first_sheet_name
];
var
jsonOutput
=
XLSX
.
utils
.
sheet_to_json
(
worksheet
);
console
.
log
(
jsonOutput
);
// Papa.parse(jsonOutput, {
// download: true,
// header : false,
// complete: function(results) {
// console.log(results.data);
// }
// });
}
xmlHttpRequest
.
send
();
//
// ending of xlsx to json coversion
//
$
(
document
).
ready
(
function
(){
$
.
getJSON
(
"
./content/content.json
"
,
function
(
result
){
stuff
=
result
;
...
...
@@ -178,4 +227,4 @@ input.addEventListener("keyup", function(event) {
document
.
getElementById
(
"
search-button_paper
"
).
click
();
}
});
\ No newline at end of file
});
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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