Exporting Stored procedure results to the Excel Sheet using Java

A

AD1234

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!
 
L

Lord Zoltar

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!

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. ;)
 
A

AD1234

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. ;)

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!
 
A

Arne Vajhøj

AD1234 said:
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
 
L

Lew

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.

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?
 
R

ram

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!

Hi
Use FOP(XML,XSLT) for that
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top