diff --git a/module/src/main/java/pl/clarin/converter/JSON2XLSX.java b/module/src/main/java/pl/clarin/converter/JSON2XLSX.java index ca6d6763152b65c17f37809f69686704a467f216..b6e4d087876b1f170edb2c2440a154e2e9bf5e31 100644 --- a/module/src/main/java/pl/clarin/converter/JSON2XLSX.java +++ b/module/src/main/java/pl/clarin/converter/JSON2XLSX.java @@ -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); }