import java.io.File;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
public class ExcelUtil {
public static void main(String[] args) {
String[] title={"编号ID","用户名","密码"};
WritableWorkbook wwb=null;
//初始化excel的文档对象:workbook工作区
String fileName="E://student.xls";
try{
//创建excel对象
wwb=Workbook.createWorkbook(new File(fileName));
//创建工作区
WritableSheet sheet=wwb.createSheet("测试", 0);
//循环表头poi jxl
Label label=null;
for(int i=0;i<title.length;i++){
//Label(i,0,title[i]) 三个参数列 行 值
label=new Label(i,0,title[i]);//创建文本
sheet.addCell(label);//往工作区添加数据
}
//写入数据
wwb.write();
//关闭流
wwb.close();
}catch(Exception e){
e.printStackTrace();
}
}
}