*
The moose likes Servlets and the fly likes showing in Excel Sheet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "showing in Excel Sheet" Watch "showing in Excel Sheet" New topic
Author

showing in Excel Sheet

amanb amanb
Greenhorn

Joined: Jan 30, 2003
Posts: 1
public ExcelReport(HttpSession session, HttpServletResponse res, Vector membershipList, Vector investmentList) throws IOException {
// BoardMember object declaration

// Set content tyoe to type ms-excel
res.setContentType("application/vnd.ms-excel");
//res.setContentType("application/msword");
// instantiate printwriter
//PrintWriter out = res.getWriter();
ServletOutputStream out = res.getOutputStream();

// Retrieve membership list from the current session
//Vector membershipList = (Vector)session.getValue(Constants.LIST);
// Set header to the Excel report
System.out.println("**************In Excel Report******************************");
InvestmentDisclosure invDisc;
// Declare company, number of shares, total amount invested and status
String userName = "";
String companyName = "";
String noOfShares = "";
String totalAmount = "";
String invStatus = "";

// Set header to the Excel report
out.println("Name\tCompany\tNumber of Shares\tTotal Amount Invested\tStatus");
// And display in a tab delimited format
for (int i=0;i<investmentList.size();i++) {
invDisc = (InvestmentDisclosure)investmentList.elementAt(i);
userName = invDisc.getFullName();
companyName = ((Company)invDisc.getCompany()).getCompanyName();
noOfShares = invDisc.getPlannedSharesNum();
totalAmount = invDisc.getInvDollarAmt();
invStatus = invDisc.getInvestmentStatus();
out.println(userName.trim() + "\t" + companyName.trim() + "\t" +
noOfShares.trim() + "\t" + totalAmount.trim() + "\t" + invStatus.trim());
}
}
The above is code I have written to show the output in Excel Sheet
But I don't know the content type is set to normal text and I don't see an Excel sheet and the output is shown in plain text.....
Can u please help me out
Urgent............
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: showing in Excel Sheet
 
Similar Threads
import HTML rows to Excel
how to extract data to an xl sheet
if (req.getMethod().equals("HEAD")) return
problem with setContentType() method
How to make an excel sheet rendered on browser read only?