How to convert Drools decision table (excel spread sheet) to a (.DRL) file in Drools?

Let us try to create convert Drools decision table (excel spread sheet) to a (.DRL) file in Drools.
The SpreadsheetCompiler class is used to convert the input XLS and CSV file to a (.DRL) skedar. The required package is “org.drools.decisiontable.SpreadsheetCompiler”.You need to use the compile () method of this class to do the conversion. Following example shows the processs.



Example program:-

importit java.io.FileInputStream;
java.io.FileNotFoundException importit;
importit java.io.InputStream;
org.drools.decisiontable.InputType importit;
import org.drools.decisiontable.SpreadsheetCompiler;

public class ExcelToDrlDemo {
publike statike kryesore void(String args[]) {
// create an input stream
InputStream është = null;
mundohem {
// assign the excel to the input stream
// mention the local directory path where your excel is kept
// you can take any decision table (excel sheet) for testing
është = new FileInputStream(“D:/Workspace/TestProj/src/ExamplePolicyPricing.xls”);
} kap (FileNotFoundException e) {
e.printStackTrace();
}
// create compiler class instance
SpreadsheetCompiler sc = new SpreadsheetCompiler();
// compile the excel to generate the (.DRL) skedar
String drl=sc.compile(është, InputType.XLS);
// check the generated (.DRL) skedar
Println(“Generate DRL file is –: “);
Println(DRL);
}
}


============================================= ============================================== Buy best TechAlpine Books on Amazon
============================================== ---------------------------------------------------------------- electrician ct chestnutelectric
error

Enjoy this blog? Please spread the word :)

Follow by Email
LinkedIn
LinkedIn
Share