Luca - this is about as simple as it gets .... YOu are simply looping through a dataset, getting each row, then formatting the row (eg. DataRow) in output (note that DataAccessObject/dataset and ValueObject/drow are objects/classes which you would need to provide) : DataAccessObject dataset = new DataAccessObject(aParameterInitializingTheSet); java.util. Collection c = dataset.getData(); // get data returns a collection of value objects for (java.util.Iterator i = c.iterator(); i.hasNext(); ){ DataRow drow = (DataRow) (i.next()); System.out.println( drow.field1 + "\t" + drow.field2 + "\t" + drow.field3 + "\t" + ... + drow.fieldn) ); } --------- However, it really all just bolis down to the code in the line using "System.out.println". Output your values, separated by tabs (or commas) and put quotes around anything which may contain a delimeter ; i.e. 1,000 should be foramatted "1,000".
--- Luca Ventura <[EMAIL PROTECTED]> wrote: > Thanks! > > I think the quicker way to do this is to use POI APIs. Anyway > it would be interesting to have a code example that implements the first > method you say: > > "Until recently, the most common way to create a Microsoft Excel file in > a Java application was to create a comma separated values (CSV) file in a > servlet or JSP and return it to the browser as MIME-type, text/csv. The > browser would then call Excel and the CSV would be displayed." > > Can someone can give me a code example that uses this method? > > Thanks. > Luca > > > -----Messaggio originale----- > Da: A mailing list for discussion about Sun Microsystem's Java Servlet API > Technology. [mailto:[EMAIL PROTECTED]]Per conto di Bob Prah > Inviato: martedi 8 ottobre 2002 21.02 > A: [EMAIL PROTECTED] > Oggetto: Re: How can I generate an Excel/Word file? > > > Hi Lucas, > > Have a look at the excerpt below which I received about two days ago. It > might help solve your problem : > > > <!-- Begin Quote --> > > CREATE EXCEL-FORMATTED DATA > > Until recently, the most common way to create a Microsoft Excel file in > a Java application was to create a comma separated values (CSV) file in a > servlet or JSP and return it to the browser as MIME-type, text/csv. The > browser would then call Excel and the CSV would be displayed. > > There is now a project that provides Java developers with a real tool > for creating Excel files. It's the most mature part of a new Jakarta > project named Poor Obfuscation Implementation (POI). The Excel > component of POI > is named Horrible Spreadsheet Format (HSSF). > > While HSSF provides many different ways of interacting with the engine, > the one we'll focus on is the easy high-level user API. > > Here's a simple example that creates a matrix of values in an Excel > sheet: > > import org.apache.poi.hssf.usermodel.*; > import java.io.FileOutputStream; > > // code run against the jakarta-poi-1.5.0-FINAL-20020506.jar. > public class PoiTest { > > static public void main(String[] args) throws Exception { > FileOutputStream fos = new FileOutputStream("foo.xls"); > HSSFWorkbook wb = new HSSFWorkbook(); > HSSFSheet s = wb.createSheet(); > wb.setSheetName(0, "Matrix"); > for(short i=0; i<50; i++) { > HSSFRow row = s.createRow(i); > > for(short j=0; j<50; j++) { > HSSFCell cell = row.createCell(j); > cell.setCellValue(""+i+","+j); > } > } > wb.write(fos); > fos.close(); > } > } > > This code first creates a workbook, gets a single sheet from that > workbook, names it, and then proceeds to write a 50x50 matrix on it. This > outputs an Excel file named foo.xls, which even opens on an Apple Mac. > > The POI project is an exciting new step for Java, bringing Windows > document integration to a new audience and allowing Java > developers to improve > the functionality of their products. > > > <!-- End Quote --> > > > Further info. can be found at : > > http://jakarta.apache.org/poi/hssf/ > > > Bob > ===== Mark Zawadzki Performance Engineer/DBA/Programmer extraordinaire’ [EMAIL PROTECTED] [EMAIL PROTECTED] "Democracies die behind closed doors," - Judge Damon Keith __________________________________________________ Do you Yahoo!? Faith Hill - Exclusive Performances, Videos & More http://faith.yahoo.com ___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html