• Post Reply Bookmark Topic Watch Topic
  • New Topic

showing in Excel Sheet  RSS feed

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!