DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: Writing to a .xls file using UTL_FILE package

  1. #1
    Join Date
    Jul 2009
    Posts
    7

    Writing to a .xls file using UTL_FILE package

    Hi,
    Can anyone help me out on writing a .xls file using the UTL_FILE package? I am able to write a .txt and .csv file. But .xls file I am not able to do .. the fields are not coming properly if I use a comma separated approach- all the data are coming in the first column itself.
    I was trying the following..

    v_buffer := '"'||rec.dept||'","'||rec.students||'"';
    UTL_FILE.PUT_LINE(v_fh, v_buffer);

    Any help in this regard will be appreciated. Thanks in advance.

    Regds,
    Abhi

  2. #2
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    You separate with comma when creating csv files, when creating xls files you want to separate with chr(9) like: rec.dept||chr(9)||rec.students
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

  3. #3
    Join Date
    Sep 2002
    Location
    England
    Posts
    7,334
    Quote Originally Posted by abhi_oracle View Post
    Hi,
    Can anyone help me out on writing a .xls file using the UTL_FILE package? I am able to write a .txt and .csv file. But .xls file I am not able to do .. the fields are not coming properly if I use a comma separated approach- all the data are coming in the first column itself.
    I was trying the following..

    v_buffer := '"'||rec.dept||'","'||rec.students||'"';
    UTL_FILE.PUT_LINE(v_fh, v_buffer);

    Any help in this regard will be appreciated. Thanks in advance.

    Regds,
    Abhi
    when you open in excel you need to specify that it is comma delimited

  4. #4
    Join Date
    Jul 2009
    Posts
    7
    Thanks a lot guys... I tried with chr(9) and it worked ..

  5. #5
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    Quote Originally Posted by abhi_oracle View Post
    I tried with chr(9) and it worked ..
    There is a reason for that, in Excel you hit TAB to move to the next cell... chr(9) = TAB
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width