// Create a new workbook Workbook workbook = new Workbook(); //Load template file Template_FamilyInfo.xlsx from resource InputStream templateFile = this.getResourceStream("xlsx/Template_FamilyInfo.xlsx"); workbook.open(templateFile); //Get data from json file String jsonText = ""; try { InputStream stream = this.getResourceStream("Template_FamilyInfo.json"); ByteArrayOutputStream result = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int length; while ((length = stream.read(buffer)) != -1) { result.write(buffer, 0, length); } jsonText = result.toString("UTF-8"); } catch (IOException e) { e.printStackTrace(); } // Create a JsonDataSource JsonDataSource datasource = new JsonDataSource(jsonText); //Add data source workbook.addDataSource("ds", datasource); //Invoke to process the template workbook.processTemplate(); // Save to an excel file workbook.save("JsonFile.xlsx");