How to export the result into different tabs of Excel in Toad for Data Analyst?

六月ゝ 毕业季﹏ 提交于 2019-11-28 12:39:47
Zoki

I'm not sure that you can do that with Toad automatically but there is a little trick that you can do with Excel.

Write first query and execute it in Toad, after that right click on query result data grid and choose "Export dataset...", under Excel format choose "Excel instance" and click OK. It will open Excel and add one sheet with data from your query.

Repeat same process for second query and it will add another sheet to same document and fill with data from second query.

After you executed all queries and added it to Excel save excel document.

If you want to do that completely automatically, there is another solution which you can use to create single Excel document with multiple sheets which are loaded with data from different queries. Purchase the third party PL/SQL package, ORA_EXCEL.

Here is example how to do that:

BEGIN  
    ORA_EXCEL.new_document;  

    ORA_EXCEL.add_sheet('Employees');  
    ORA_EXCEL.query_to_sheet('select * from employees');  

    ORA_EXCEL.add_sheet('Departments');  
    ORA_EXCEL.query_to_sheet('select * from departments', FALSE);  

    ORA_EXCEL.add_sheet('Locations');  
    ORA_EXCEL.query_to_sheet('select * from locations');  

    -- EXPORT_DIR is an Oracle directory with at least  
    -- write permission  
    ORA_EXCEL.save_to_file('EXPORT_DIR', 'example.xlsx');  
END;

It can generate Excel file and store it to Oracle directory, or you can get generated Excel file into PL/SQL BLOB variable so you can store it to table or create your own process to distribute file like sending it to email.

More details you can find on products documentation/examples page: http://www.oraexcel.com/examples

Cheers

I don't think this functionality exists in TOAD.

The usual solution for exporting straight from PL/SQL to Excel - Tom Kyte's OWA_SYLK wrapper for the SYLK api - only works with single worksheets. There are a couple of alternative solutions.

Sanjeev Sapre has his get_xl_xml package. As the name suggests it uses XML to undertake the transformation. Find out more.

Jason Bennett has written a PL/SQL object which generates an Excel XML document. Find out more.

You no longer need to write code to output data for multiple sheets. As long as your SQL has queries identified clearly (with semicolons), TDA or now TDP will automatically dump data for different SQLs in different worksheets.

Jimmy

I have Toad for Data Analyst 2.6. I use the keyword GO between queries.

Select * from tableA;

GO

Select * from tableB;

This creates two tabs in Excel.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!