• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to see ms-Excel file from servlets  RSS feed

 
maggie karve
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello People.........

I wrote a code in html to just invoke the servlet and my servlet code goes like this



i just get to see the html page ....I expect to see an excel file with the data values..I tried posting the http link in excel file but didnt work..I am not sure how to see it.....
Kindly help...

Thanks in advance
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That looks like tab-delimited text file, not an Excel file. Unless you set a Content-Disposition header there's no reason why Excel should open it. Start reading here: http://www.coderanch.com/how-to/java/JspAndExcel
 
soundar rajan
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Your question is not clear. If you want to read data from excel file , you have to use some third party libraries like POI, you can download the POI jar file using the following maven dependencies:

<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.8</version>
</dependency>

Sample code for reading excel file using the POI api :

import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
//..
FileInputStream file = new FileInputStream(new File("C:\\test.xls"));

//Get the workbook instance for XLS file
HSSFWorkbook workbook = new HSSFWorkbook(file);

//Get first sheet from the workbook
HSSFSheet sheet = workbook.getSheetAt(0);

//Get iterator to all the rows in current sheet
Iterator<Row> rowIterator = sheet.iterator();

//Get iterator to all cells of current row
Iterator<Cell> cellIterator = row.cellIterator();


Please rephrase your question and post again.
 
Abhay Agarwal
Ranch Hand
Posts: 1376
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
using open source Apache POI may be the best option for you.
Search online for examples on Apache POI.

~ abhay
 
Regina Thomas
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have MS-Excel or compatible software available on the computer you tested on?

Q...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!