Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2008

Tip: Looking for answers? Try searching our database.

Exporting Stored procedure results to the Excel Sheet using Java

Thread view: 
AD1234 - 26 Mar 2008 19:21 GMT
Hi,

I want to export the results generate by stored procedure or query to
the Excel format using Java.
Any help would be appreciated.

Thanks!
Lord Zoltar - 26 Mar 2008 19:41 GMT
> Hi,
>
[quoted text clipped - 3 lines]
>
> Thanks!

Do you need special Excel-specific formatting? If not, the easiest way
to get the data into Excel is probably a CSV file, as Excel can open
CSV files without a problem.
If you need basic formatting, you can put your data into a formatted
HTML table and then save is as a file with an XLS extension - it's a
bit of a hack, but for simple purposes, it works just fine.
If you want to get fancy and export macros or something, well then,
uh... I dunno. ;)
AD1234 - 26 Mar 2008 23:31 GMT
> > Hi,
>
[quoted text clipped - 12 lines]
> If you want to get fancy and export macros or something, well then,
> uh... I dunno. ;)

Well. Thanks for a quick reply.

The stored procedure is not really complex. It is like (select top 10
* from clients).
The constraint is, it has to be a stored procedure. Not a direct SQL
statement.
Also, it should export results in Excel Sheet format. Not really well
formatting required.

If you can link up some example or some way it would be a good help.

Thanks!
Arne Vajhøj - 27 Mar 2008 00:33 GMT
> The stored procedure is not really complex. It is like (select top 10
> * from clients).
> The constraint is, it has to be a stored procedure. Not a direct SQL
> statement.
> Also, it should export results in Excel Sheet format. Not really well
> formatting required.

I assume you know how to call your SP using CallableStatement.

To write to Excel you have at least 3 options:

1)  Write a CSV file which Excel reads fine. This is by far
    the easiest.

2)  Use Apache POI to write a XLS file.

3)  Use JDBC ODBC bridge and ODBC driver for Excel to
    write XLS file.

Arne
Lew - 27 Mar 2008 05:10 GMT
AD1234 wrote:
>> The stored procedure is not really complex. It is like (select top 10
>> * from clients).
>> The constraint is, it has to be a stored procedure. Not a direct SQL
>> statement.
>> Also, it should export results in Excel Sheet format. Not really well
>> formatting required.

> I assume you know how to call your SP using CallableStatement.
>
[quoted text clipped - 7 lines]
> 3)  Use JDBC ODBC bridge and ODBC driver for Excel to
>     write XLS file.

AD1234, "Excel Sheet" format is many formats - Excel excels at reading many.
There is perhaps an engineering reason why you think you need to use its
(current) native format?  If so, please share it.  If not, just use any format
that works.  Preferably the easiest one to write from Java.

What does "Not really well formatting required" mean?

Signature

Lew

ram - 28 Mar 2008 10:28 GMT
> Hi,
>
[quoted text clipped - 3 lines]
>
> Thanks!

Hi
Use FOP(XML,XSLT) for that


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.