0

Is there any way that I can export data fetched from a SQL query in a PL/SQL procedure to an Excel or PDF file?

The export must be done within the procedure itself.

Ben
  • 51,770
  • 36
  • 127
  • 149
APPSfreak
  • 1
  • 1
  • 1
    What, exactly, do you mean by "EXCEL file"? You can relatively easily generate a CSV file which Excel will happily open. It's more complicated, but you can also generate an XML file that can be opened by newer versions of Excel. If you are trying to generate an XLS or XLSX binary file, that is also possible but probably requires resorting to a Java stored procedure. – Justin Cave Apr 13 '13 at 09:55
  • im aware that i can generate a CSV file and then open it with Excel..I was wondering if there is any way which will generate an excel output file instead of a CSV file.. – APPSfreak Apr 13 '13 at 09:57
  • Does that mean that you want to generate a binary XLS file? An XLSX file? Or something else? – Justin Cave Apr 13 '13 at 10:06
  • Yes @APPSfreak. You can call the file `myfile.xls` instead of `mfile.csv`... It's a hack but when opened it'll appear the same. – Ben Apr 13 '13 at 10:47
  • FWIW, PL/SQL Developer from AllRound Automation can export a result set directly into Excel. I've written code before to generate XML that Excel can read, but I found it loaded into Excel v...e....r....r....r....y s...l....o...o...o...w....l....y. CSV performance is much better - and much more compact as well. BTW - IIRC Excel will honor double-quotes around fields if they're needed because the field holds a string value which happens to contain commas. Share and enjoy. – Bob Jarvis - Слава Україні Apr 14 '13 at 00:01
  • you can also use SQL*Plus to generate HTML foramt (using `SET MARKUP HTML` look [here](http://docs.oracle.com/cd/B10500_01/server.920/a90842/ch8.htm#1005745)). excel knows how to read html format. this is a very bad solution though. – haki Apr 14 '13 at 13:36

0 Answers0