jsp 如何调用java类里的public static void main(String argv[]) {中的main方法?
这个类如下
package CylClass;
//public class XlsToTable {
// public XlsToTable() {
// }
//}
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.hssf.record.*;
import org.apache.poi.hssf.model.*;
import org.apache.poi.hssf.util.*;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate;
import java.io.FileInputStream;
public class XlsToTable {
public static String fileToBeRead = "E:/a.xls ";
public static void main(String argv[]) {
try {
HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(
fileToBeRead));
HSSFSheet sheet = workbook.getSheet( "Sheet1 ");
int rows = sheet.getPhysicalNumberOfRows();
for (int r = 0; r < rows; r++) {
HSSFRow row = sheet.getRow(r);
if (row != null) {
int cells = row.getPhysicalNumberOfCells();
String value = " ";
for (short c = 0; c < cells; c++) {
HSSFCell cell = row.getCell(c);
if (cell != null) {
switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_FORMULA:
//
break;
case HSSFCell.CELL_TYPE_NUMERIC:
value += (long) cell.getNumericCellValue()
+ "\t ";
break;
case HSSFCell.CELL_TYPE_STRING:
value += cell.getStringCellValue() + "\t ";
break;
default:
value += "\t ";
}
}
}
// 下面可以将查找到的行内容用SQL语句INSERT到oracle