Home » Developer & Programmer » Forms » unable to read excel file
unable to read excel file [message #529515] Tue, 01 November 2011 12:17 Go to next message
swapnil_naik
Messages: 269
Registered: December 2009
Location: Mumbai
Senior Member

I am trying to create excel file thru form....in form i create button Excel

WHEN -BUTTON - PRESSED :

Quote:

DECLARE
CURSOR C1 IS
SELECT DEPTNO,DNAME,LOC FROM DEPT;
filename varchAr2(256);
convid pls_integer;
appid pls_integer;
buffer varchar2(5);
i number(3) := 1;
j number(3) := 1;
v_number varchar2(5);
len number(5);
dname varchar2(14);
loc varchar2(13);
out_file text_io.file_type;

begin
filename := get_file_name(file_filter=> 'EXCEL FILES(*.XLS)|*.XLS|',DIALOG_TYPE => 2);
OUT_FILE := TEXT_IO.FOPEN(filename,'W');
TEXT_IO.FCLOSE(OUT_FILE);

Appid := dde.app_begin('C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE'||filename,DDE.APP_MODE_MINIMIZED);
CONVID := DDE.InitiAte('EXCEL.EXE',filename);

for r in c1
loop
dde.poke(convid,'R'||J||'C1',R.DEPTNO,DDE.CF_TEXT,1000);
Dde.poke(convid,'R'||J||'C2',R.DNAME,DDE.CF_TEXT,1000);
dde.poke(convid,'R'||J||'C3',R.LOC,DDE.CF_TEXT,1000);
J:= J+1 ;
END LOOP;
TEXT_IO.FCLOSE(OUT_FILE);
EXCEPTION
WHEN DDE.DDE_APP_NOT_FOUND THEN MESSAGE('1');
WHEN DDE.DDE_APP_FAILURE THEN MESSAGE('2');
WHEN DDE.DDE_INIT_FAILED THEN MESSAGE('3');
WHEN DDE.DMLERR_NO_CONV_ESTABLISHED THEN MESSAGE('4');
WHEN OTHERS THEN MESSAGE(SQLERRM);
END;




My excel file opened but it shows unable to read file
i dont know what happens..

My excel version is 2003..
Re: unable to read excel file [message #529522 is a reply to message #529515] Tue, 01 November 2011 12:31 Go to previous messageGo to next message
Littlefoot
Messages: 21815
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I wouldn't know, sorry.

But, I think that YOU, being a member of this forum for 2 years, should have learnt how to use [code] tags which make your code easier to read.
Re: unable to read excel file [message #529523 is a reply to message #529522] Tue, 01 November 2011 12:35 Go to previous messageGo to next message
swapnil_naik
Messages: 269
Registered: December 2009
Location: Mumbai
Senior Member

DECLARE
CURSOR C1 IS
SELECT DEPTNO,DNAME,LOC FROM DEPT;
filename varchAr2(256);
convid pls_integer;
appid pls_integer;
buffer varchar2(5);
i number(3) := 1;
j number(3) := 1;
v_number varchar2(5);
len number(5);
dname varchar2(14);
loc varchar2(13);
out_file text_io.file_type;

begin
filename := get_file_name(file_filter=> 'EXCEL FILES(*.XLS)|*.XLS|',DIALOG_TYPE => 2);
OUT_FILE := TEXT_IO.FOPEN(filename,'W');
TEXT_IO.FCLOSE(OUT_FILE);

Appid := dde.app_begin('C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE'||filename,DDE.APP_MODE_MINIMIZED);
CONVID := DDE.InitiAte('EXCEL.EXE',filename);

for r in c1 
loop
dde.poke(convid,'R'||J||'C1',R.DEPTNO,DDE.CF_TEXT,1000);
Dde.poke(convid,'R'||J||'C2',R.DNAME,DDE.CF_TEXT,1000);
dde.poke(convid,'R'||J||'C3',R.LOC,DDE.CF_TEXT,1000);
J:= J+1 ;
END LOOP;
TEXT_IO.FCLOSE(OUT_FILE);
EXCEPTION
WHEN DDE.DDE_APP_NOT_FOUND THEN MESSAGE('1');
WHEN DDE.DDE_APP_FAILURE THEN MESSAGE('2');
WHEN DDE.DDE_INIT_FAILED THEN MESSAGE('3');
WHEN DDE.DMLERR_NO_CONV_ESTABLISHED THEN MESSAGE('4');
WHEN OTHERS THEN MESSAGE(SQLERRM);
END;


Sir, i want to create excel file by using this code...but while opening excel file it give me error unable to read file..
Re: unable to read excel file [message #529537 is a reply to message #529523] Tue, 01 November 2011 13:02 Go to previous messageGo to next message
Littlefoot
Messages: 21815
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Nice code tags! However, your code is still unformatted and difficult to read.


Yes, I agree, I'm useless - the fact is, I never did that. I'm just trying to make it easier for other people who might know how to help, so that they wouldn't need to read your unreadable code.
Re: unable to read excel file [message #529540 is a reply to message #529537] Tue, 01 November 2011 13:08 Go to previous messageGo to next message
swapnil_naik
Messages: 269
Registered: December 2009
Location: Mumbai
Senior Member

DECLARE
   CURSOR C1 IS
          SELECT DEPTNO,DNAME,LOC FROM DEPT;
filename varchAr2(256);
convid pls_integer;
appid pls_integer;
buffer varchar2(5);
i number(3) := 1;
j number(3) := 1;
v_number varchar2(5);
len number(5);
dname varchar2(14);
loc varchar2(13);
out_file text_io.file_type;

begin
   filename := get_file_name(file_filter=> 'EXCEL   FILES(*.XLS)|*.XLS|',DIALOG_TYPE => 2);
    OUT_FILE := TEXT_IO.FOPEN(filename,'W');
    TEXT_IO.FCLOSE(OUT_FILE);

Appid := dde.app_begin('C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE'||filename,DDE.APP_MODE_MINIMIZED);

CONVID := DDE.InitiAte('EXCEL.EXE',filename);

for r in c1 
 loop
   dde.poke(convid,'R'||J||'C1',R.DEPTNO,DDE.CF_TEXT,1000);
   Dde.poke(convid,'R'||J||'C2',R.DNAME,DDE.CF_TEXT,1000);
   dde.poke(convid,'R'||J||'C3',R.LOC,DDE.CF_TEXT,1000);

   J:= J+1 ;
  END LOOP;
   TEXT_IO.FCLOSE(OUT_FILE);

EXCEPTION
WHEN DDE.DDE_APP_NOT_FOUND THEN MESSAGE('1');
 WHEN DDE.DDE_APP_FAILURE THEN MESSAGE('2');
  WHEN DDE.DDE_INIT_FAILED THEN MESSAGE('3');
    WHEN DDE.DMLERR_NO_CONV_ESTABLISHED THEN MESSAGE('4');
      WHEN OTHERS THEN MESSAGE(SQLERRM);
END;
Re: unable to read excel file [message #529575 is a reply to message #529540] Wed, 02 November 2011 00:20 Go to previous messageGo to next message
swapnil_naik
Messages: 269
Registered: December 2009
Location: Mumbai
Senior Member

friends, please help me.
Re: unable to read excel file [message #531100 is a reply to message #529575] Sun, 13 November 2011 06:43 Go to previous message
aallan
Messages: 150
Registered: October 2011
Senior Member
use webutil...
if u configerd a webutil let me know to explain code u need...
Previous Topic: Problem with Tree
Next Topic: f60util.pll
Goto Forum:
  


Current Time: Thu Aug 01 08:37:56 CDT 2024