package com.xxxx;
import java.io.File;
import java.io.IOException;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import jxl.write.Label;
import jxl.write.Number;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import jxl.write.biff.RowsExceededException;
public class U_WriteExcel {
static WritableWorkbook wworkbook;
static WritableSheet wsheet;
static {
try {
wworkbook = Workbook.createWorkbook(new File("output.xls"));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public static void execute(int startRow, int startColumn, String content) throws IOException, RowsExceededException, WriteException, BiffException
// throws BiffException, IOException, WriteException
{
wsheet = wworkbook.createSheet("Test Result", 0);
Label label = new Label(0, 0, "Test Case Name");
Label label1 = new Label(1, 0, "Result");
wsheet.addCell(label);
wsheet.addCell(label1);
Label writeResult = new Label(startRow,startColumn, content);
System.out.println(startRow);
System.out.println(startColumn);
System.out.println(content);
wsheet.addCell(writeResult);
wworkbook.write();
}
}
我从另一个班级打电话给上面的班级......
U_WriteExcel.execute(0,1,"Test Case 1");
U_WriteExcel.execute(1,1,"PASSED");
U_WriteExcel.execute(0,2,"Test Case 2");
U_WriteExcel.execute(1,2,"PASSED");
表上没有写任何内容。如何解决这个问题??