web stats
Excel As Data Source - Page 2 - Mirth Community

Go Back   Mirth Community > Mirth Connect > Development

Reply
 
Thread Tools Display Modes
  #11  
Old 07-27-2011, 01:31 AM
doanhuy doanhuy is offline
Mirth Newb
 
Join Date: Mar 2011
Location: HoChiMinh, VietNam
Posts: 18
doanhuy is on a distinguished road
Default

Hi All,
I got a error as below when I used jxl.jar library:
"Wrapped jxl.read.biff.PasswordException: The workbook is password protected"
When I opened in hand, excel file didn't require a password.

After read this file, I want to delete it. Can I do it and how?
Thanks,
Huy

Last edited by doanhuy; 07-27-2011 at 08:12 PM.
Reply With Quote
  #12  
Old 10-31-2012, 01:23 PM
CasperSHO CasperSHO is offline
OBX.1 Kenobi
 
Join Date: Jan 2012
Location: Netherlands
Posts: 38
CasperSHO is on a distinguished road
Default

Hi,

This works great, the only thing is dat it keeps looping through the excel file because the source connector is polling every 5 secs. What I want is to stop processing the excel file once it reached the last row. Any ideas?

Casper
Reply With Quote
  #13  
Old 11-05-2012, 06:39 AM
marmanold marmanold is offline
Mirth Newb
 
Join Date: Feb 2011
Location: Franklin, TN
Posts: 9
marmanold is on a distinguished road
Default

I would add some additional code at the end to move the file to an archive directory after processing.
__________________
Michael Arnold| Electronic Data Interchange Specialist

PlayMaker CRM
Sales Innovation for Home Care
A Division of The ADAM Group
115 Southeast Parkway Court | Franklin, TN 37064
866.930.6847 | F: 866.232.6470 | PlayMakerCRM.com
Reply With Quote
  #14  
Old 08-26-2013, 11:40 PM
kashif kashif is offline
OBX.1 Kenobi
 
Join Date: Jan 2008
Location: Aga Khan Universitiy Hospital
Posts: 41
kashif
Default excel read

Hi I am trying this code to read exel file and I am getting error below. please help.


======== code =============

importPackage(Packages.jxl.Workbook);

//List to store each Excel row in
var excelData = new Packages.java.util.ArrayList();


//Open an Excel file
var excelBook = new Packages.jxl.Workbook;
var excel = excelBook.getWorkbook(excelBook);

var excelFile = new Packages.java.io.File("C:\Users\Test\Desktop\New folder\test.xls");
excel = Packages.jxl.Workbook.getWorkbook(excelFile);



//Read in the first sheet
var sheet = excel.getSheet(0);

//Variables for the current row and column
var myRow = 1;
var myCol = 0;

//Variable for the last row or last column
var rowStop = 0;
var colStop = 0;

while (rowStop == 0) {
var msgString = '<result>';
while (colStop == 0) {
//See if this column is valid
//If so, write the cell
try {
//logger.error(sheet.getCell(myCol, myRow).getContents());
msgString = msgString + '<col' + myCol + '>' + sheet.getCell(myCol, myRow).getContents() + '</col' + myCol + '>';
}
//If not, stop processing at this column and move on to the next row.
catch(ex) {
colStop = 1;
}
myCol++;
}
myRow++;
myCol = 0;
colStop = 0;

//See if the next row is valid
try {
sheet.getCell(myCol, myRow);
}
//If not, stop processing the Excel file.
catch(ex) {
rowStop = 1;
}

msgString = msgString + '</result>';

//Clear out invalid XML characters
msgString = msgString.replace(/&/g, '&amp;');
msgString = msgString.replace(/\'/g, '&apos;');
msgString = msgString.replace(/\"/g, '&quot;');

//Add the message to the message list
var msgXML = new XML(msgString.toString());
excelData.add(msgXML.toString());
}

//Close the Excel file
excel.close()

return excelData;




==============ERROR ===================

[2013-08-27 12:33:17,802] ERROR (com.mirth.connect.connectors.js.JavaScriptReceive r:94): Error executing JavaScript Reader script 32f9f5d6-9b5a-4747-aedf-b1f9fad9ebf4.
com.mirth.connect.server.util.javascript.JavaScrip tExecutorException: com.mirth.connect.server.MirthJavascriptTransforme rException: CHANNEL:
xl_to_xmlCONNECTOR:
SourceSOURCE CODE:
10: return AttachmentUtil.createAttachment(connectorMessage, data, type);11: }12: function validate(mapping, defaultValue, replacement) {var result = mapping;if ((result == undefined) || (result.toString().length == 0)) { if (defaultValue == undefined) { defaultValue = ''} result = defaultValue; } result = new java.lang.String(result.toString()); if (replacement != undefined) {for (i = 0; i < replacement.length; i++) { var entry = replacement[i]; result = result.replaceAll(entry[0], entry[1]); } } return result; }function createSegment(name, msgObj, index) {if (arguments.length == 1) { return new XML('<' + name + '></' + name + '>'); };if (arguments.length == 2) { index = 0; };msgObj[name][index] = new XML('<' + name + '></' + name + '>');return msgObj[name][index];}13: function createSegmentAfter(name, segment) {var msgObj = segment;while (msgObj.parent() != undefined) { msgObj = msgObj.parent(); }msgObj.insertChildAfter(segment[0], new XML('<' + name + '></' + name + '>'));return msgObj.child(segment[0].childIndex() + 1);}14: function doScript() {15: importPackage(Packages.jxl.Workbook);16: //importPackage(JavaClassjxl.Workbook);17: 18: //List to store each Excel row in19: var excelData = new Packages.java.util.ArrayList();LINE NUMBER:
15DETAILS:
Function importPackage must be called with a package; had "[JavaClass jxl.Workbook]" instead.
at 32f9f5d6-9b5a-4747-aedf-b1f9fad9ebf4:15 (doScript)
at 32f9f5d6-9b5a-4747-aedf-b1f9fad9ebf4:87
at com.mirth.connect.server.util.javascript.JavaScrip tUtil.execute(JavaScriptUtil.java:62)
at com.mirth.connect.connectors.js.JavaScriptReceiver .poll(JavaScriptReceiver.java:92)
at com.mirth.connect.donkey.server.channel.PollConnec tor$PollConnectorTask.run(PollConnector.java:125)
at java.util.TimerThread.mainLoop(Unknown Source)
at java.util.TimerThread.run(Unknown Source)Caused by: com.mirth.connect.server.MirthJavascriptTransforme rException: CHANNEL:
xl_to_xmlCONNECTOR:
SourceSOURCE CODE:
10: return AttachmentUtil.createAttachment(connectorMessage, data, type);11: }12: function validate(mapping, defaultValue, replacement) {var result = mapping;if ((result == undefined) || (result.toString().length == 0)) { if (defaultValue == undefined) { defaultValue = ''} result = defaultValue; } result = new java.lang.String(result.toString()); if (replacement != undefined) {for (i = 0; i < replacement.length; i++) { var entry = replacement[i]; result = result.replaceAll(entry[0], entry[1]); } } return result; }function createSegment(name, msgObj, index) {if (arguments.length == 1) { return new XML('<' + name + '></' + name + '>'); };if (arguments.length == 2) { index = 0; };msgObj[name][index] = new XML('<' + name + '></' + name + '>');return msgObj[name][index];}13: function createSegmentAfter(name, segment) {var msgObj = segment;while (msgObj.parent() != undefined) { msgObj = msgObj.parent(); }msgObj.insertChildAfter(segment[0], new XML('<' + name + '></' + name + '>'));return msgObj.child(segment[0].childIndex() + 1);}14: function doScript() {15: importPackage(Packages.jxl.Workbook);16: //importPackage(JavaClassjxl.Workbook);17: 18: //List to store each Excel row in19: var excelData = new Packages.java.util.ArrayList();LINE NUMBER:
15DETAILS:
Function importPackage must be called with a package; had "[JavaClass jxl.Workbook]" instead.
at 32f9f5d6-9b5a-4747-aedf-b1f9fad9ebf4:15 (doScript)
at 32f9f5d6-9b5a-4747-aedf-b1f9fad9ebf4:87
at com.mirth.connect.server.util.javascript.JavaScrip tUtil.executeScript(JavaScriptUtil.java:466)
at com.mirth.connect.connectors.js.JavaScriptReceiver $JavaScriptReceiverTask.call(JavaScriptReceiver.ja va:117)
at java.util.concurrent.FutureTask$Sync.innerRun(Unkn own Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run Task(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (Unknown Source)
at java.lang.Thread.run(Unknown Source)
Reply With Quote
  #15  
Old 12-17-2013, 07:04 PM
sar1234 sar1234 is offline
What's HL7?
 
Join Date: Dec 2013
Posts: 1
sar1234 is on a distinguished road
Default How to read the excel file throw mirth connect

How to read the excel file through mirth connect? please share the channel.
Reply With Quote
  #16  
Old 09-18-2018, 02:14 PM
clarksss clarksss is offline
OBX.2 Kenobi
 
Join Date: Jul 2013
Posts: 63
clarksss is on a distinguished road
Default

Quote:
Originally Posted by bernd05 View Post
Hi,

I've tried to follow your instructions, but when I try to use the Channel I reveiced an error saying:

Code:
[2011-07-08 09:55:32,817]  
FATAL (org.mule.impl.DefaultComponentExceptionStrategy:84): The error is: null
java.lang.NullPointerException
	at com.webreach.mirth.connectors.js.JavaScriptMessageReceiver.poll(JavaScriptMessageReceiver.java:88)
	at org.mule.providers.PollingMessageReceiver.run(PollingMessageReceiver.java:90)
	at org.mule.impl.work.WorkerContext.run(WorkerContext.java:290)
	at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
	at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
	at java.lang.Thread.run(Unknown Source)
[2011-07-08 09:54:52,754]  
FATAL 
(org.mule.impl.DefaultComponentExceptionStrategy:83): The Default Component Exception Strategy has been invoked but there is no current event on the context
[2011-07-08 09:51:07,408]  
ERROR 
(com.webreach.mirth.connectors.js.JavaScriptMessageReceiver:152): org.mozilla.javascript.EcmaError: TypeError: Cannot call property getWorkbook in object [JavaPackage jxl.Workbook]. It is not a function, it is "object". (62c52ab0-7111-48f0-bafc-db7bccfbb578#9)
Any hints for me?

Thanks, Regards,
- Bernd
I recycled the Mirth Service.. that worked for me.. (ensure your .jar is the custom-lib folder)

Boom !
Reply With Quote
Reply

Tags
excel, java, jexcel

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 03:48 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation