用JSP的话提示Exception
rg.apache.jasper.JasperException: common/Assert
...
没有什么意义。在linux服务器上面运行的话,竟然提示:Exception in thread "main" java.lang.NoClassDefFoundError: HelloJXL
代码如下,在Windows下面运行得了,到linux下操作同一个文件就不行了:
import java.io.File;
import jxl.Workbook;
import jxl.Sheet;
import jxl.Cell;
import jxl.NumberCell;
import jxl.DateCell;
import jxl.CellType;
public class HelloJXL{
public static void main(String[] args){
Workbook workbook = null;
try {
workbook = Workbook.getWorkbook(new File("test.xls"));
Sheet sheet = workbook.getSheet(0);
int rows = sheet.getRows();
int cols = sheet.getColumns();
Cell cell = null;
for (int i = 0;
i < rows;
i++){
System.out.print("Next line begin
:");
boolean bbegin
= true;
for (int j = 0;
j < cols;
j++){
if (bbegin
) bbegin
= false;
else
System.out.print(", ");
cell = sheet.getCell(j, i);
if (cell.getType() == CellType.NUMBER)
System.out.print(((NumberCell)cell).getValue());
else
if (cell.getType() == CellType.DATE)
System.out.print(((DateCell)cell).getDate());
else
System.out.print(cell.getContents());
}
}
workbook.close();
} catch (Exception e){
workbook.close();
workbook = null;
e.printStackTrace();
}
}
}