Suyash
Suyash

Reputation: 341

How to export select query data into excel file using Oracle query?

I have a query which generates reports for a particular day. Is there any query where in Oracle with export it into excel? I dont want to manually export it. Am using oracle developer.

Upvotes: 3

Views: 23363

Answers (2)

Marcus
Marcus

Reputation: 3869

If you are using Oracle SQL devloper:

Export Query Output to Excel in Oracle SQL Developer without spooling:

Step 1: Run your query. To start, you'll need to run your query in SQL Developer. ...
Step 2: Open the Export Wizard. ...
Step 3: Select the Excel format and the location to export your file. ...
Step 4: Export the query output to Excel.

For example:

enter image description here

If you are not using wizard then other way to do this is using below commands:

@export on;
@export set CsvColumnDelimiter=";";
@export set ShowNullAs="";
@export set filename="/home/xxx.csv";


select * from XX_TABLE;

@export off;

Upvotes: 4

Popeye
Popeye

Reputation: 35900

You need to use SPOOL and you can not directly write to .xls file, You need to write data to .csv file and open it in Excel.

set sqlformat csv
spool d:\your_file.csv
select * from your_table;
spool off;

Cheers!!

Upvotes: 4

Related Questions