Link to home
Create AccountLog in
Avatar of 1500orion

asked on

sqlplus to excel output formatting


I have a question on formatting the column width in Excel from Sqlplus. I want to specify this from sqlplus for each column.

I am outputting the data from a pl/sql proc that is being called from sqlplus using the dbms_output package.

Thanks for any assistance.
Avatar of Ravindran Gopinathan
Ravindran Gopinathan
Flag of United States of America image

Can you please explain how you are creating Excel from SQL Plus? Based on the code we can see if it possible to adjust the column width or not.. Are you spooling the contents to a CSV file?

You can use rpad, lpad commands to pad spaces to your output columns.
SQL> begin
  2   dbms_output.put_line(rpad('col1',10)||rpad('col2',5));
  3  end;
  4  /
col1      col2
PL/SQL procedure successfully completed.

Open in new window

>formatting the column width in Excel from Sqlplus
not possible as SQLPlus generates no ExcelSheet.
All you can do is to export a (comma)-delimited file for import in excel then

meikl ;-)
Avatar of 1500orion


I am spooling tab delimited (chr(09)) which automatically opens in Excel format without importing. I know in Sqlplus without declaring a proc I have accomplished this by using something such as

column "col a" format a9

colmna "col a"
from dual;

But in this case I need this with the DMBS_OUTPUT package declared in a proc... and the alias column is not recongnized defined is not recongnized in the proc.

I will try the padding the data as suggestedwhich I have not yet and see if this will expand the columns...
Avatar of dbmullen
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account