Home » Developer & Programmer » Forms » ole2 error reading excel from Form6i (Form 6i , win xp)
ole2 error reading excel from Form6i [message #560277] |
Wed, 11 July 2012 12:03 |
irfankundi786@yahoo.com
Messages: 269 Registered: February 2009 Location: pakistan
|
Senior Member |
|
|
i am using ole2 to read excel sheet using form 6i.
i am using loop for the next row of excel sheet to read but after reading the ist row , loop generate error.
I hanled the exception in exception section the message of error is Ora-305500 Non-oracle exception
Can any one help me to solve this problem...
I also past the code here....
PROCEDURE READEXCELOLE IS
APPLICATION OLE2.OBJ_TYPE;
WORKBOOKS OLE2.OBJ_TYPE;
WORKBOOK OLE2.OBJ_TYPE;
WORKSHEETS OLE2.OBJ_TYPE;
WORKSHEET OLE2.OBJ_TYPE;
CELL OLE2.OBJ_TYPE;
SROW NUMBER:=0;
COL NUMBER:=0;
CELLVALUE VARCHAR2(89);
V_RC_1 VARCHAR2(1000);
V_RC_2 VARCHAR2(1000);
V_RC_3 VARCHAR2(1000);
V_RC_4 VARCHAR2(1000);
V_RC_5 VARCHAR2(1000);
V_RC_6 VARCHAR2(1000);
ARGS OLE2.OBJ_TYPE;
BEGIN
--------------INITIATE EXCEL APPLICATION---------------------------
APPLICATION := OLE2.CREATE_OBJ('EXCEL.APPLICATION');
OLE2.SET_PROPERTY(APPLICATION,'VISIBLE','TRUE');
WORKBOOKS := OLE2.GET_OBJ_PROPERTY(APPLICATION, 'WORKBOOKS');
----------------OPEN REQUIRED WORKBOOK-----------------------------
ARGS := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(ARGS,:VFILE);
WORKBOOK := OLE2.GET_OBJ_PROPERTY(WORKBOOKS,'OPEN',ARGS);
OLE2.DESTROY_ARGLIST(ARGS);
----------------OPEN REQUIRED WORKSHEET---------------------------
ARGS := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(ARGS,1);
WORKSHEET := OLE2.GET_OBJ_PROPERTY(WORKBOOK,'WORKSHEETS',ARGS);
OLE2.DESTROY_ARGLIST(ARGS);
----------------GET CELL VALUE-------------------------------------
LOOP
SROW := SROW+1;
-----------------------COLUMN1-------------------------------------
ARGS := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(ARGS,SROW);
OLE2.ADD_ARG(ARGS,1);
CELL := OLE2.GET_OBJ_PROPERTY(WORKSHEET,'CELLS',ARGS);
OLE2.DESTROY_ARGLIST(ARGS);
ARGS := OLE2.CREATE_ARGLIST;
V_RC_1 := OLE2.GET_CHAR_PROPERTY(CELL,'TEXT');
-----------------------COLUMN2-------------------------------------
ARGS := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(ARGS,SROW);
OLE2.ADD_ARG(ARGS,2);
CELL := OLE2.GET_OBJ_PROPERTY(WORKSHEET,'CELLS',ARGS);
OLE2.DESTROY_ARGLIST(ARGS);
ARGS := OLE2.CREATE_ARGLIST;
V_RC_2 := OLE2.GET_CHAR_PROPERTY(CELL,'TEXT');
-----------------------COLUMN3-------------------------------------
ARGS := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(ARGS,SROW);
OLE2.ADD_ARG(ARGS,3);
CELL := OLE2.GET_OBJ_PROPERTY(WORKSHEET,'CELLS',ARGS);
OLE2.DESTROY_ARGLIST(ARGS);
ARGS := OLE2.CREATE_ARGLIST;
V_RC_3 := OLE2.GET_CHAR_PROPERTY(CELL,'TEXT');
-----------------------COLUMN4-------------------------------------
ARGS := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(ARGS,SROW);
OLE2.ADD_ARG(ARGS,4);
CELL := OLE2.GET_OBJ_PROPERTY(WORKSHEET,'CELLS',ARGS);
OLE2.DESTROY_ARGLIST(ARGS);
ARGS := OLE2.CREATE_ARGLIST;
V_RC_4 := OLE2.GET_CHAR_PROPERTY(CELL,'TEXT');
-----------------------COLUMN5-------------------------------------
ARGS := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(ARGS,SROW);
OLE2.ADD_ARG(ARGS,5);
CELL := OLE2.GET_OBJ_PROPERTY(WORKSHEET,'CELLS',ARGS);
OLE2.DESTROY_ARGLIST(ARGS);
ARGS := OLE2.CREATE_ARGLIST;
V_RC_5 := OLE2.GET_CHAR_PROPERTY(CELL,'TEXT');
-----------------------COLUMN6-------------------------------------
ARGS := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(ARGS,SROW);
OLE2.ADD_ARG(ARGS,6);
CELL := OLE2.GET_OBJ_PROPERTY(WORKSHEET,'CELLS',ARGS);
OLE2.DESTROY_ARGLIST(ARGS);
ARGS := OLE2.CREATE_ARGLIST;
V_RC_6 := OLE2.GET_CHAR_PROPERTY(CELL,'TEXT');
IF V_RC_6 IS NULL THEN
EXIT;
END IF;
---------------INSERT THE VALUE IN THE TABLE ---------------------
INSERT INTO EMP VALUES(V_RC_1,V_RC_2,V_RC_3,V_RC_4,V_RC_5,V_RC_6);
END LOOP;
--END LOOP;
COMMIT;
----------------CLOSE THE EXCEL SHEET AFTER READING--------------
OLE2.INVOKE(APPLICATION,'QUIT');
-----------------RELEASE ALL OBJECTS -----------------------------
OLE2.RELEASE_OBJ(CELL);
OLE2.RELEASE_OBJ(WORKSHEET);
OLE2.RELEASE_OBJ(WORKBOOK);
OLE2.RELEASE_OBJ(WORKBOOKS);
OLE2.RELEASE_OBJ(APPLICATION);
END;
|
|
|
Goto Forum:
Current Time: Sun Sep 01 16:06:26 CDT 2024
|