我正在读取一个excel文件,现在我想将它传递给jsp文件。
我需要将test
对象传递给 jsp 文件,以便将其显示给浏览器。
import java.io.IOException;
import java.io.*;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
public class Readexcl
{
private String inputFile;
public void setInputFile(String inputFile) {
this.inputFile = inputFile;
}
public void read() throws IOException {
File inputWorkbook = new File(inputFile);
Workbook w;
try {
w = Workbook.getWorkbook(inputWorkbook);
Sheet sheet = w.getSheet(0);
for (int i = 0; i < sheet.getRows(); i++)
{
Cell cell = sheet.getCell(0, i);
System.out.print(cell.getContents()+" ");
cell = sheet.getCell(1, i);
System.out.println(cell.getContents()+" ");
//cell = sheet.getCell(2, i);
//System.out.println(cell.getContents());
}
}
catch (BiffException e)
{
e.printStackTrace();
}
}
public static void main(String[] args) throws IOException {
Readexcl test = new Readexcl();
test.setInputFile("c:\\DATA.xls");
test.read();
}
}