Lotus Notes - Llamada a librería Java

   
Vista:

Llamada a librería Java

Publicado por Jesús (5 intervenciones) el 26/11/2008 09:26:00
Hola:
tengo una libreria en java y necesito coger datos de ella desde un agente lotuscript.
En options del agente pongo Use "nombre de la libreria" y la llamo con call "nombre de la libreria" pero me da error.
Si alguien sabe cual es la sintaxis correcta para llamar a la librería...
Saludos y gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Llamada a librería Java

Publicado por Noel Reyes (6 intervenciones) el 01/12/2008 17:43:10
todo parese bien...

estas utilizando parentesis al llamarla ??

call libreria_java()

saludos!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Llamada a librería Java

Publicado por Jesús (5 intervenciones) el 02/12/2008 08:43:52
Sí, pero me dice que no es un nombre de función o subfunción
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Llamada a librería Java

Publicado por ElLobo (1 intervención) el 16/06/2015 12:27:29
Este ejemplo no funcionara ya que faltan clases LotusScript pero vale como ejemplo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
'============================================
La clase Javascript
'============================================
 
Option Public
Option Declare
 
UseLSX "*javacon"    '<-- Importante


Use "class:baseObject" '<--- Clase javascript
Use "java:POI"   '<--- Clase Java


Public Class POI As baseObject

	oClass As JavaClass
	oSession As JavaSession
	oObj As Variant 
	'=========================================================
	Sub New(), baseObject()
 
		On Error GoTo Control_Error
 
		classname="POI"
 
		Set me.oSession = New JavaSession()
		Set me.oClass 	= me.oSession.GetClass("POI")
		Set me.oObj 	= me.oClass.CreateObject()
 
		Exit Sub
		'=====================================================================
Control_Error: Call AddToStackTraceObj( Me )
		'====================================================================
		Error Err , Error
		Exit Sub
	End Sub
 
	%REM
		Function getDestino
		Description: Comments for Function
	%END REM
	Function getWorkBook( sFileName As String ) As Variant
 
		On Error GoTo Control_Error
 
		Set getWorkBook = me.oObj.getWorkBook(sFileName)
 
		Exit Function
		'=====================================================================
Control_Error: Call AddToStackTraceObj( Me )
		'====================================================================
		Error Err , Error
		Exit Function
	End Function
	Function getLibro( sFileName As String ) As Variant
 
		On Error GoTo Control_Error
 
		Set getLibro = me.oObj.getLibro(sFileName)
 
		Exit Function
		'=====================================================================
Control_Error: Call AddToStackTraceObj( Me )
		'====================================================================
		Error Err , Error
		Exit Function
	End Function
 
	%REM
		Function CellToString
		Description: Comments for Function
	%END REM
	Function CellToString( oCell As Variant ) As String
		If IsNull( oCell ) Then
			CellToString =  ""
		Else
 
			CellToString =  me.oObj.cellToString(oCell)
		End If
 
	End Function
 
	%REM
		Function toJSON
		Description: Comments for Function
	%END REM
	Function toJSON( sFileName As String , sSheetName As String ) As Variant
 
		Dim oWorkBook As Variant,oSheet As Variant
		Dim nRows As Integer , nCols As Integer, nCol As Integer , nRow As Integer
		Dim oRow As Variant , oCell As Variant
		Dim oJSON As Variant , oJSONArray As Variant
 
		Set oWorkBook = me.getWorkBook( sFileName )
 
		Set oSheet = oWorkBook.getSheet(sSheetName)
 
		nRows = oSheet.getLastRowNum()
		nCols = oSheet.getRow(0).getLastCellNum() -1
 
		Set oJSON		= NewObj("JSONObject")
		Set oJSONArray 	= newObj("JSONArray")
 
		For nRow=0 To nRows
 
			Set oRow =  oSheet.getRow(nRow)
 
			With NewObj("JSONObject")
 
				Call .AddItem( "row" , nRow )
 
				For nCol=0 To nCols
 
					If isVacio(oRow ) Then
						Call .AddItem( "col" & nCol, "" )
					Else
						If IsObject(oRow.getCell(nCol)) Then
							Set oCell = oRow.getCell(nCol)
 
							If isVacio(oCell) Then
								Call .AddItem( "col" & nCol, "" )
							Else
								Call .AddItem( "col" & nCol, me.cellToString(oCell) )
							End If
 
						Else
							Call .AddItem( "col" & nCol, oRow.getCell(nCol) )
						End If
					End If
 
				Next
 
				Call oJSONArray.AddItem( .this() )
 
			End With
		Next
 
		Call oJSON.addItem( "total" 	, nRows+1)
		Call oJSON.addItem( "success" 	, True )
		Call oJSON.addItem( "rows" 		, oJSONArray )
		Call oJSON.addItem( "path" 		, sFileName )
		Call oJSON.addItem( "sheet" 	, sSheetName )
 
		Set toJSON = oJSON
 
	End Function
	%REM
		Sub saveTo
		Description: Comments for Sub
	%END REM
	Sub saveTo( oWorkbook as Variant  ,  sFullPath As String )
		Call me.oObj.saveTo( oWorkbook , sFullPath )
	End Sub
 
End Class


=======================================
La clase Java
=======================================

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import java.io.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
 
public class POI{
 
	public HSSFWorkbook getWorkBook( String sFileName ) throws Exception
	{
		File excel = new File ( sFileName );
        FileInputStream fis = new FileInputStream(excel);
 
        HSSFWorkbook wb = new HSSFWorkbook(fis);
 
        return wb;
	}
 
	public Workbook getLibro( String sFileName ) throws Exception
	{
		File excel = new File ( sFileName );
        FileInputStream fis = new FileInputStream(excel);
 
        Workbook  wb = WorkbookFactory.create(fis);
 
        return wb;
	}
	public static String cellToString (HSSFCell cell) throws Exception
	   {
 
	    	int type;
	    	Object result;
 
	    	if (cell==null)
	    	{
	    		return "";
	    	}
 
	    	type = cell.getCellType();
 
	    	    switch(type) {
 
 
	    	    case 0://numeric value in excel
	    	        result = new Double(cell.getNumericCellValue());
	    	        break;
	    	    case 1: //string value in excel
	    	        result = cell.getStringCellValue();
	    	        break;
	    	    case 2: //boolean value in excel
	    	        result = new Boolean( cell.getBooleanCellValue ());
	    	        break;
	    	    case HSSFCell.CELL_TYPE_BLANK:
	    	    	result = new String();
	    	        break;
	    	    default:
	    	       throw new Exception("Tipo de Celda no soportado " + type);
	    	        }
 
	    	    return result.toString();
 
	    	}
 
	public void saveTo( Workbook  oWorkbook , String sFullPath ) throws Exception
	{
		try {
            FileOutputStream out = new FileOutputStream(new File( sFullPath ));
 
            oWorkbook.write(out);
            out.close();
 
            System.out.println("Excel written successfully..");
 
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
 
	}
}
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar