-1

Possible Duplicate:
Create an Excel Spreadsheet from a Oracle Database
Writing in ExcelSheet using UTL_FILE package in Oracle

I am generating CSV file with the UTIL_File package.

Now I would like to format the header in bold when it is opened in MS Excel.

Is there any way to do that using PL/SQL and Oracle 9i?

Thanks

Community
  • 1
  • 1
Avi
  • 1,115
  • 8
  • 20
  • 30
  • 1
    CSV files *acnnot* contain formatting, just data in plain text. Oracle has no built-ins to export data to Oracle's proprietary format but other people have written extensions. See my answer in the thread I have proposed as a duplicate, as it suggests several different options for you. – APC Jul 17 '12 at 11:30

2 Answers2

3

A csv file is a plain text document, without any formatting. So by definition it is not possible to open a csv file in excel and have the headers in bold.

You could write a vba macro in Excel that opens the csv file, copies the content to an excel sheet and applies whatever formatting you require.

assylias
  • 321,522
  • 82
  • 660
  • 783
  • actualy i m generating csv file and keeping it in some folder ,from there java has to attach this file to mail and send. Now tell me how can i do that... I m bit new to PL/SQL. Thanks – Avi Jul 17 '12 at 08:56
  • 1
    You can't include formatting in a csv file. If you want some formatting, you need to use a different file format. – assylias Jul 17 '12 at 09:01
  • but in that case how can i generate xls or anything using Oracle 9i Can we do the same using UTIL_FILE. – Avi Jul 17 '12 at 09:06
  • 1
    I don't know oracle well enough to answer that. Since you read the file from java, you can use the apache-poi library or a similar tool to create an excel file from the csv file, including the required formatting. See [this tutorial](http://www.avajava.com/tutorials/lessons/how-do-i-write-to-an-excel-file-using-poi.html) for an example. – assylias Jul 17 '12 at 09:09
3

CSV is a plain-text format, it does not allow for any formatting information. If formatting is a must, you could try creating an XML Excel file: http://blogs.msdn.com/b/brian_jones/archive/2005/06/27/433152.aspx

Be aware that this is quite a bit more complicated than creating a CSV file, but it will allow you to create a file that contains formatting information.

FrustratedWithFormsDesigner
  • 26,726
  • 31
  • 139
  • 202