Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
nlpworkers
converter
Commits
c8ca5a0d
Commit
c8ca5a0d
authored
Feb 22, 2021
by
Tomasz Walkowiak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code reafctor
parent
9239a081
Pipeline
#2555
passed with stage
in 1 minute and 54 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
3 deletions
+14
-3
module/src/main/java/pl/clarin/converter/JSON2XLSX.java
module/src/main/java/pl/clarin/converter/JSON2XLSX.java
+14
-3
No files found.
module/src/main/java/pl/clarin/converter/JSON2XLSX.java
View file @
c8ca5a0d
...
...
@@ -13,6 +13,7 @@ import java.util.HashMap;
import
org.apache.poi.xssf.usermodel.XSSFRow
;
import
org.apache.poi.xssf.usermodel.XSSFSheet
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
...
...
@@ -24,15 +25,25 @@ public class JSON2XLSX {
int
key_id
=
0
;
HashMap
<
String
,
Integer
>
keys
=
new
HashMap
<>();
private
void
process
(
String
fileIn
,
JSONObject
options
,
XSSFRow
row
,
int
column
)
throws
Exception
{
String
content
=
new
String
(
Files
.
readAllBytes
(
Paths
.
get
(
fileIn
)));
JSONObject
json
=
new
JSONObject
(
content
);
for
(
String
key:
json
.
keySet
())
{
if
(!
keys
.
containsKey
(
key
))
{
keys
.
put
(
key
,
new
Integer
(
key_id
++));
{
double
value
=
0
;
try
{
value
=
json
.
getDouble
(
key
);
}
double
value
=
json
.
getDouble
(
key
);
catch
(
JSONException
e
)
{
continue
;
}
if
(!
keys
.
containsKey
(
key
))
{
keys
.
put
(
key
,
key_id
++);
}
row
.
createCell
(
column
+
keys
.
get
(
key
)).
setCellValue
(
value
);
}
...
...
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