Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using POI in converting Exel format to textfile format

843836Dec 15 2004 — edited Sep 25 2006
Hi Guys!!!
Im creating a web application using jsp and servlet..I decided to use apache POI in converting the excel to textfile..Some expert recommended to use this method since im dealing with java technology..

Here is the example code taken to the site: A quick guide to use HSSF/POI,
(indicated below)

My problem is How will i use this code and modify it..The action will be to write the data from EXCEL to TEXTFILE format..If you have an idea or another sample code please send me..Need your Help!!thankyou


Reading and Rewriting Workbooks
POIFSFileSystem fs =
new POIFSFileSystem(new FileInputStream("workbook.xls"));
HSSFWorkbook wb = new HSSFWorkbook(fs);
HSSFSheet sheet = wb.getSheetAt(0);
HSSFRow row = sheet.getRow(2);
HSSFCell cell = row.getCell((short)3);
if (cell == null)
cell = row.createCell((short)3);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setCellValue("a test");

// Write the output to a file
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 23 2006
Added on Dec 15 2004
15 comments
695 views