You don't "access" rules in excel, you define rules in excel which are
generated and loaded into the knowledge base as you have done below.
You then need to create a session, add some facts to it and execute it:
Eg:
If collection is a collection of the facts you want to run through your model then:
StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession();
ksession.execute( collection );
Thomas
-----Original Message-----
From: rules-users-bounces(a)lists.jboss.org [mailto:rules-users-
bounces(a)lists.jboss.org] On Behalf Of Sanjib Karmakar
Sent: 30 June 2010 13:52
To: rules-users(a)lists.jboss.org
Subject: [rules-users] Request for help to execute rule using drools5.0 from
excel file
Hi
I am new in drools and in my project I would like to access rules in excel
file using drools 5.0
Please provide me the source code for how to access the rules in excel file.
I have done the following code
KnowledgeBuilder kBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
DecisionTableConfiguration dtconf =
KnowledgeBuilderFactory.newDecisionTableConfiguration();
dtconf.setInputType( DecisionTableInputType.XLS );
dtconf.setWorksheetName("Tables");
kBuilder.add(ResourceFactory.newFileResource("TeamAllocationExample.xls"),
ResourceType.DTABLE, dtconf);
KnowledgeBuilderErrors errors = kBuilder.getErrors();
if (errors.size() > 0)
{
for (KnowledgeBuilderError error: errors) {
System.out.println(error);
}
throw new IllegalArgumentException("Could not parse knowledge.");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kBuilder.getKnowledgePackages());
return kbase;
I am using the 'TeamAllocationExample.xls' - which is the default example I
found searching in net.
Here LHS and RHS portions are given - I would like to know how could I
execute the rule and get the result what is given under 'ACTION' column?
Please help me.
Thanks in advance
Sanjib
--
View this message in context:
http://drools-java-rules-
engine.46999.n3.nabble.com/Request-for-help-to-execute-rule-using-drools5-0-
from-excel-file-tp933111p933111.html
Sent from the Drools - User mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
**************************************************************************************
This message is confidential and intended only for the addressee. If you have received
this message in error, please immediately notify the postmaster(a)nds.com and delete it from
your system as well as any copies. The content of e-mails as well as traffic data may be
monitored by NDS for employment and security purposes. To protect the environment please
do not print this e-mail unless necessary.
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United
Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603
8808 40-00
**************************************************************************************