利用java excel api 将内容写如一个excel文件。
package writeexcel;
import java.io.File;
import java.io.IOException;
import jxl.*;
import jxl.write.*;
import jxl.write.Number;
import jxl.write.biff.RowsExceededException;
public class WriteExcel {
public static void main(String[] args) throws IOException, RowsExceededException, WriteException {
WritableWorkbook myworkbook = Workbook.createWorkbook(new File("E:\\java-SRC\\ExcelAPILearning\\write.xls"));
WritableSheet mysheet = myworkbook.createSheet("First",0);
Number number = new Number(3,4,3.14159);
mysheet.addCell(number);
myworkbook.write();
myworkbook.close();
}
}
在D5的位置写入一个数: 3.14159。语句也很简单,只是表达一个意思而已。