cancel
Showing results for 
Search instead for 
Did you mean: 

writing resultSet from a query to an excel file

Former Member
0 Kudos

Hello @ all

I want to download the content of database table to an excel file.

The connection to the database and the selection of the data is not the problem. But writing the ResultSet to an excel file is the problem.

the scenario is: the user clicks on a FileDownload-uiElement and then the application gets the data from the database and the user can store the file on his local filesystem (e.g. c:\template.xls)

I hope you can help me.

Thanks a lot.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

hi

Can you please let us know the solution...

regards,

Sushil Jain

Former Member
0 Kudos

Thanks for your efforts.

I'm a fool, i solved it on my own already.

Former Member
0 Kudos

Hi,

To create excel files you can use apache POI.

http://poi.apache.org/

Regards

Ayyapparaj

Former Member
0 Kudos

I know that I can use POI, but the FileDownload-UIElement which I want to use, needs an attribute of type Resource.

my current code looks like this (will be executed by a method called in wdDoInit):

ResultSet resultS = null;

DataSource dataSource = getDataSource();

if (dataSource != null)

{

connect = dataSource.getConnection();

if (connect != null)

{

stateM = connect.createStatement();

resultS = stateM.executeQuery("SELECT * FROM mytable);

ResultSetMetaData rsMD = resultS.getMetaData();

int col = rsMD.getColumnCount();

IWDResource res = null;

while (resultS.next())

{

String content = resultS.getString(2);

byte[] b = content.getBytes();

res = WDResourceFactory.createCachedResource(b, MainTransDatView.FILE_NAME, WDWebResourceType.XLS);

}

wdContext.currentResourceNodeElement().setResource(res);

}

}

Edited by: Claudia Sass on Jan 31, 2008 10:09 AM

Former Member