Commit c8ca5a0d authored by Tomasz Walkowiak's avatar Tomasz Walkowiak

Code reafctor

parent 9239a081
Pipeline #2555 passed with stage
in 1 minute and 54 seconds
......@@ -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);
}
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);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment