File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "showing in Excel Sheet" Watch "showing in Excel Sheet" New topic

showing in Excel Sheet

amanb amanb

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
// 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
I agree. Here's the link:
subject: showing in Excel Sheet
It's not a secret anymore!