Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
am using forloop for getnumbersheets in excel file in javaclass.how can i display sheetnames in jsp with radiobutton for all sheets

What I have tried:

package com;

import java.io.FileInputStream;

import java.io.IOException;
import java.util.ArrayList;

import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class ExcelDataParser
{
private ArrayList<string>arr;

public ArrayList<string> getArr() {
return arr;
}

public void setArr(ArrayList<string> arr) {
this.arr = arr;
}
//public static void getSheetNames()
public static void main(String args[]) throws IOException
{
ArrayList<string> arr=new ArrayList<string>();

try {
String str="C:\\Downloads\\Associate_Details.xlsx";

FileInputStream fileInputStream = null;

fileInputStream = new FileInputStream(str);
XSSFWorkbook workbook = new XSSFWorkbook(fileInputStream);
String work;
for (int i = 0; i < workbook.getNumberOfSheets(); i++)
{

work=workbook.getSheetName(i);
arr.add(work);
}
System.out.println(arr);
workbook.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}}

}
Posted
Updated 14-Oct-17 1:06am

1 solution

In order to show the output in jsp page you have to use out.write(); method.so, inside your for loop use
out.write("<input type="radio">"+work+"<br>");
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900