cancel
Showing results for 
Search instead for 
Did you mean: 

service task: read data from excel via JavaDelegates

bonsoir
Champ in-the-making
Champ in-the-making
Hi everyone,

Sorry to bother. As a newbie, i have a question regarding read data(specific cell from xls file) and filter the value with an exclusive gateway. after searching around the internet and forum, i still can't find a proper way to do it, no matter with groovy or javascript.

Could anyone be kind to shed me some light on this one?


i've searched for javascript code as following:

function GetData(cell,row){
     var excel = new ActiveXObject("Excel.Application");
     var excel_file = excel.Workbooks.Open("C:\test.xls");
     var excel_sheet = excel.Worksheets("Sheet1");
   var data = excel_sheet.Cells(cell,row).Value;
   return data;
   }
document.write(GetData(1,1));

However this one returns "org.activiti.engine.ActivitiException: coudn't deserialize value 'sun.org.mozilla.javascript.internal.InterpretedFunction@87e0dc' in variable 'GetData'"
4 REPLIES 4

frederikherema1
Star Contributor
Star Contributor
Hi,

Activiti uses client-side Javascripting, no I'm not sure if you're able to use "new ActiveXObject("Excel.Application");", as the ScriptBindings are not aware of these things. Can't you write a JavaDelegate that reads and extracts what'n needed from the XLS?

bonsoir
Champ in-the-making
Champ in-the-making
Hi,

Activiti uses client-side Javascripting, no I'm not sure if you're able to use "new ActiveXObject("Excel.Application");", as the ScriptBindings are not aware of these things. Can't you write a JavaDelegate that reads and extracts what'n needed from the XLS?

Would you please be kind to show me an example?  Thank you for your suggestion. Smiley Happy

frederikherema1
Star Contributor
Star Contributor
Thats something Larry Page can help you with, google will get you on the way. There are a number of good ways of reading XLS in java, rather CSV's or full-blown XLSX's…

gbucsariu
Champ in-the-making
Champ in-the-making
Try EasyXLS.
http://www.easyxls.com
It is a java library and you may read write xls, xlsx and xlsb files.