Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
converter
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nlpworkers
converter
Commits
c8ca5a0d
There was an error fetching the commit references. Please try again later.
Commit
c8ca5a0d
authored
4 years ago
by
Tomasz Walkowiak
Browse files
Options
Downloads
Patches
Plain Diff
Code reafctor
parent
9239a081
No related merge requests found
Pipeline
#2555
passed with stage
in 1 minute and 54 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
module/src/main/java/pl/clarin/converter/JSON2XLSX.java
+14
-3
14 additions, 3 deletions
module/src/main/java/pl/clarin/converter/JSON2XLSX.java
with
14 additions
and
3 deletions
module/src/main/java/pl/clarin/converter/JSON2XLSX.java
+
14
−
3
View file @
c8ca5a0d
...
@@ -13,6 +13,7 @@ import java.util.HashMap;
...
@@ -13,6 +13,7 @@ import java.util.HashMap;
import
org.apache.poi.xssf.usermodel.XSSFRow
;
import
org.apache.poi.xssf.usermodel.XSSFRow
;
import
org.apache.poi.xssf.usermodel.XSSFSheet
;
import
org.apache.poi.xssf.usermodel.XSSFSheet
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
...
@@ -24,15 +25,25 @@ public class JSON2XLSX {
...
@@ -24,15 +25,25 @@ public class JSON2XLSX {
int
key_id
=
0
;
int
key_id
=
0
;
HashMap
<
String
,
Integer
>
keys
=
new
HashMap
<>();
HashMap
<
String
,
Integer
>
keys
=
new
HashMap
<>();
private
void
process
(
String
fileIn
,
JSONObject
options
,
XSSFRow
row
,
int
column
)
throws
Exception
{
private
void
process
(
String
fileIn
,
JSONObject
options
,
XSSFRow
row
,
int
column
)
throws
Exception
{
String
content
=
new
String
(
Files
.
readAllBytes
(
Paths
.
get
(
fileIn
)));
String
content
=
new
String
(
Files
.
readAllBytes
(
Paths
.
get
(
fileIn
)));
JSONObject
json
=
new
JSONObject
(
content
);
JSONObject
json
=
new
JSONObject
(
content
);
for
(
String
key:
json
.
keySet
())
for
(
String
key:
json
.
keySet
())
{
if
(!
keys
.
containsKey
(
key
))
{
double
value
=
0
;
{
keys
.
put
(
key
,
new
Integer
(
key_id
++));
try
{
value
=
json
.
getDouble
(
key
);
}
catch
(
JSONException
e
)
{
continue
;
}
}
double
value
=
json
.
getDouble
(
key
);
if
(!
keys
.
containsKey
(
key
))
{
keys
.
put
(
key
,
key_id
++);
}
row
.
createCell
(
column
+
keys
.
get
(
key
)).
setCellValue
(
value
);
row
.
createCell
(
column
+
keys
.
get
(
key
)).
setCellValue
(
value
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
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!
Save comment
Cancel
Please
register
or
sign in
to comment