IBM alphaWorks, http://www.alphaworks.ibm.com/, has a suite of JavaBeans
called ExcelAccessor that will let you access and modify Excel worksheets.
The URL for the download page is rather cryptic, so just do a search from
the alphaWorks home page to find it if the below url does not work.
http://www.alphaworks.ibm.com/aw.nsf/frame?ReadForm&/ab.nsf/techmain/F3B93B9
3A95816A18825672600059928
An alternative method of working with spreadsheet data is to export it as a
delimited text file and work with it that way. However, this method isn't
always practical.
Also, the following example is available from
http://www.coolservlets.com/developer/tips/tip04.html
Produce MS Excel files dynamically
public class TransManager extends HttpServlet {
public void service( HttpServletRequest request, HttpServletResponse
response )
throws IOException
{
response.setContentType("application/vnd.ms-excel");
PrintWriter out = new PrintWriter(response.getWriter());
response.setHeader("Content-Disposition","attachment;filename=foo.xls");
// set up the SQL as a string
String str = "select * from footable";
// load the database driver here eg:oracle
Class.forName(oracle.forName("oracle.jdbc.driver.OracleDriver"));
// get a connection
Connection con =
DriveManager.getConnection("jdbc:SomeJDBCurl","user","passsword");
Statement stmt = con.createStatement();
// Get the result set
while(rs.next()) {
ResultSet rs = stmt.executeQuery(str);
// Display headings in excel
try {
ResultSetMetaData rsm = rs.getMetaData();
int cx;
for(cx = 1; cx <= rsm.getColumnCount(); cx++) {
if (cx > 1) {
out.print("\t");
}
out.print(rsm.getColumnName(cx));
}
out.println("");
} catch (SQLException se) {
se.printStackTrace();
}
// display rows
while(rs.next()) {
for(rx = 1; rx <= rsm.getColumnCount(); rx++) {
if (rx > 1) {
out.print("\t");
}
Object obj = rs.getObject(rx);
if (obj != null) {
out.print(obj.toString());
}
else {
out.print("");
}
}
HTH,
Todd
-----Original Message-----
From: Michael Wentzel [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 16, 2001 12:05 PM
To: '[EMAIL PROTECTED]'
Subject: RE: Excel to XML
>
> Jianming Wang
>
If you're talking strictly data you could make an odbc
connection and suck out the data that way. If you're
talking about the whole ball of wax(formatting, precision,
data, etc.) you are probably going to need to right some
native(c++) code and use the M$ components to interact
with excel files. M$ has a knack of slipping little
things in here and there so that it makes it difficult for
others to do anything with their stuff(i.e. remember that
whole M$ jvm/J++ fiasco). Alternately, I'm sure someone
has written a commercial API to interact directly with
excel files and get more information than just the data,
but of course this costs money.
HTH
---
Michael Wentzel
Software Developer
Software As We Think - http://www.aswethink.com
mailto:[EMAIL PROTECTED]
- Punisher of those who cannot spell dumb!
The information in this electronic mail ("e-mail") message may
be confidential and for use of only the named recipient. The
information may be protected by privilege, work product immunity
or other applicable law. If you are not the intended recipient
the retention, dissemination, distribution or copying of this
e-mail message is strictly prohibited. If you receive this e-mail
message in error please notify us immediately by telephone
at 770-723-1011 or [EMAIL PROTECTED] Thank you.