'Reading Drool Rules from multiple Sheets in one Excel
I am trying to read multiple sheets rules from one excel sheet.
I used kieFileSystem.write(ResourceFactory.newClassPathResource("{path of excel sheet}"));
But it is reading from only 1st sheet i.e Rules-1 how to read rules form sheet2 also into same session while loading one excel sheet.
Below attached the excel with 2 sheets format.
Solution 1:[1]
Drools decision tables do not support multiple sheets in a single workbook. As you found, if you try to provide multiple sheets, it will only read the first.
The solution is to use multiple workbooks.
Solution 2:[2]
Drools always read the first sheet, so you need to swap your sheet before the kieFileSystem.write()
XSSFWorkbook workbook = new XSSFWorkbook("file path");
workbook.setSheetOrder(code,0);
workbook.setActiveSheet(0);//to make sure everything is fine
File outputFile = new File("tempExcel"+".xlsx");
FileOutputStream fos = new FileOutputStream(outputFile);
workbook.write(fos);
workbook.close();
fos.close();
//here do your kieFileSystem.write(outputFile)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Roddy of the Frozen Peas |
| Solution 2 | Ibrahim_Fneich |

