poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wulf Wechsung ...@contexo.de>
Subject AW: Use of HSSF for Excel interface with Database?
Date Mon, 17 Mar 2003 15:03:17 GMT

Hi Ogh,

if plattform is not an issue for you, you can use odbc for that purpose.
One requirement though: Your tables need to be extremly well formed (header,
data thats it, no fancy stuff). I made a convinience API that makes opening
odbc datasources a charm. It can also create new ones or delete existing. 
For working on tables you can use either a JDBC Connection or the
abstraction I made, which basically returns javax.swing.TableModel's instead
of RecordSets. It's not very well documented (yet :), but includes testcases
and a sample application. If you want to you use it, just email me and I'll
send it to you (no need to pollute the mailing list :).

Steps for doing it without my code (Win2k):

First you need to register your excel file as odbc datasource

Got to Control Panel -> Administrative Tools -> Data Sources -> Choose
Excel-Files and 'New', the rest should be self-explaining, do remember the
name you gave your new datasource though

some sample code:

// The jdbc driver you'll be using (is included in the J2SE)
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
			
//Connection string where ds_name must be the datasource name you assigned
before
con = DriverManager.getConnection("jdbc:odbc:ds_name","",""); 
	
//sample select where sheet_name is the name of, well, the sheet you want to
work with
// for some strange reason, "[ $]" has to be there.
select = con.prepareStatement("select * from
[sheet_name$]",ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);


Hope that helped!

Cheers,
Wulf


-----Ursprungliche Nachricht-----
Von: Qgh Rohgy [mailto:questanser@yahoo.com]
Gesendet: Samstag, 15. Marz 2003 03:23
An: poi-user@jakarta.apache.org
Betreff: Use of HSSF for Excel interface with Database?


Hello,

I have a project which need an excel interface for the
users to create/update/delete multiple records in the
database tables.

Could I use POI HSSF API for this purpose?

I went through the API and realized that there is no
easy way to do so. Unless I find the value of each
Cell in the Excel file.

Example :-

Date   Amount
3/13    20
3/14    25
3/12    15
3/13    10


I have 2 columns in my XLS file 
Date and Amount.

I want to update values in my Database of rows whose
Date is greater than 3/12.

Is there an efficent way of querying this in HSSF and
then updating the Db table?

Is it possible? How should I do it?

Is there any other API that I could use?

Thanks in advance,
qgh

__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - establish your business online
http://webhosting.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org

Mime
View raw message