Home » Developer & Programmer » Forms » how to print text in center while generating .csv file using oracle forms (oracle 10g d2k6i)
how to print text in center while generating .csv file using oracle forms [message #631210] Sat, 10 January 2015 06:26 Go to next message
jgjeetu
Messages: 373
Registered: July 2013
Location: www.Orafaq.com/Forum
Senior Member

PROCEDURE GEN_EXCEL IS

IN_FILE TEXT_IO.FILE_TYPE;
VC_HEAD Varchar2(32000);


BEGIN

IN_FILE := TEXT_IO.FOPEN('C:\'||'123.CSV','W'); 
TEXT_IO.PUT_LINE(IN_FILE,'EMPLOYEE DETAILS'||chr(10));
VC_HEAD := 'EMPNO,ENAME,JOB,MGR,SAL,COMM,DEPTNO';

TEXT_IO.PUT_LINE(IN_FILE,VC_HEAD);
FOR C1 IN ( SELECT EMPNO,ENAME,JOB,MGR,SAL,COMM,DEPTNO FROM EMP) LOOP

TEXT_IO.PUT_LINE(IN_FILE,C1.EMPNO||','||C1.ENAME||','||C1.JOB||','||C1.MGR||','||C1.SAL||','||C1.COMM||','||C1.DEPTNO);


END LOOP;

TEXT_IO.FCLOSE(IN_FILE);
MESSAGE('Excel file has been created!');
MESSAGE('Excel file has been created!');

EXCEPTION
WHEN NO_DATA_FOUND THEN
TEXT_IO.FCLOSE(IN_FILE);
MESSAGE('Error while writing file');
MESSAGE('Error while writing file');
END;


I have made this procedure to print query output in .csv format so that i could open it using excel.
i created this procedure in program units in forms and used procedure name on push button .
and when i presson it gives me output :-
/forum/fa/12433/0/


now my requirement is i want to print employee details header in center of .csv file.
TEXT_IO.PUT_LINE(IN_FILE,'EMPLOYEE DETAILS'||chr(10));


please tell me how to achieve this.
  • Attachment: emp.JPG
    (Size: 47.60KB, Downloaded 2146 times)
Re: how to print text in center while generating .csv file using oracle forms [message #631322 is a reply to message #631210] Mon, 12 January 2015 13:12 Go to previous messageGo to next message
joy_division
Messages: 4963
Registered: February 2005
Location: East Coast USA
Senior Member
Add a couple of commas before the string "employee details?"
Re: how to print text in center while generating .csv file using oracle forms [message #631360 is a reply to message #631322] Tue, 13 January 2015 01:59 Go to previous messageGo to next message
wency
Messages: 450
Registered: April 2006
Location: Philippines
Senior Member

Try this.

Merge the columns in first row, probably 8 columns

http://www.orafaq.com/forum/t/77825/2/

[Updated on: Tue, 13 January 2015 02:29]

Report message to a moderator

Re: how to print text in center while generating .csv file using oracle forms [message #631390 is a reply to message #631322] Tue, 13 January 2015 06:35 Go to previous messageGo to next message
jgjeetu
Messages: 373
Registered: July 2013
Location: www.Orafaq.com/Forum
Senior Member

Add a couple of commas before the string "employee details?"


this method would work only in that case if i know the total number of columns , but what in case if i dont know the number of columns or there is only text to print ? it doesn't fulfill my requirement, anyways thanks to all for the reply Smile

[Updated on: Tue, 13 January 2015 06:45]

Report message to a moderator

Re: how to print text in center while generating .csv file using oracle forms [message #631404 is a reply to message #631390] Tue, 13 January 2015 09:12 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
If you're creating a csv Joy's solution is the only option.
csv has no concept of formatting, it just has commas and data.
So to get want you want you'll have to work out how many columns you have and add the appropriate number of commas.
Re: how to print text in center while generating .csv file using oracle forms [message #631416 is a reply to message #631404] Tue, 13 January 2015 19:59 Go to previous messageGo to next message
wency
Messages: 450
Registered: April 2006
Location: Philippines
Senior Member

So you need to merge the columns and print in center. CSV is excel file saved as text anyway.
Re: how to print text in center while generating .csv file using oracle forms [message #631433 is a reply to message #631404] Wed, 14 January 2015 01:16 Go to previous messageGo to next message
jgjeetu
Messages: 373
Registered: July 2013
Location: www.Orafaq.com/Forum
Senior Member

thanks for letting me know, i was expecting few keywords like center middle or something else. Laughing thanks @cm @wenky.

[Updated on: Wed, 14 January 2015 01:17]

Report message to a moderator

Re: how to print text in center while generating .csv file using oracle forms [message #631457 is a reply to message #631416] Wed, 14 January 2015 02:33 Go to previous message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
wency wrote on Wed, 14 January 2015 01:59
CSV is excel file saved as text anyway.

It might be better to think of csv as a plain text file that just happens to be in a format excel can read.
You can't do anything with a csv that can't be done in notepad.
Previous Topic: FRM-41104
Next Topic: sign_webutil.bat
Goto Forum:
  


Current Time: Tue Apr 23 14:39:20 CDT 2024