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) fil. 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:-

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

public class ExcelToDrlDemo {
public static void main(String args[]) {
// create an input stream
InputStream är = null;
prova {
// 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
är = ny FileInputStream(“D:/Workspace/TestProj/src/ExamplePolicyPricing.xls”);
} fånga (FileNotFoundException e) {
e.printStackTrace();
}
// create compiler class instance
SpreadsheetCompiler fm = ny SpreadsheetCompiler();
// compile the excel to generate the (.DRL) fil
String drl=sc.compile(är, InputType.XLS);
// check the generated (.DRL) fil
System.out.println(“Generate DRL file is –: “);
System.out.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