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."
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-----Hi Lucas,
Da: A mailing list for discussion about Sun Microsystem's Java Servlet API Technology. [mailto:[EMAIL PROTECTED]]Per conto di Bob Prah
Inviato: martedì 8 ottobre 2002 21.02
A: [EMAIL PROTECTED]
Oggetto: Re: How can I generate an Excel/Word file?
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