jxl导出excel_数据类型
程序员文章站
2022-03-11 12:03:17
...
项目中涉及到数据的导出处理:备查如下
WritableWorkbook wwb = null;
wwb = Workbook.createWorkbook(filename);
// 创建Excel工作表
WritableSheet ws = wwb.createSheet("通讯录", 0);// 创建sheet
Label label = new Label(0, 0, "1", getNormolCell());
ws.addCell(label);
jxl.write.Number labelN = new jxl.write.Number(0, 1, 10000);// 数字类型
ws.addCell(labelN);
jxl.write.DateFormat df = new jxl.write.DateFormat("yyyy年M月d日");// 添加带有formatting的DateFormat对象
jxl.write.WritableCellFormat wcfDF = new jxl.write.WritableCellFormat(
df);
Label labelDTF = new Label(1, 2, "2007年10月07日", wcfDF);
ws.addCell(labelDTF);
// 数字文本
jxl.write.WritableCellFormat contentFromart = new jxl.write.WritableCellFormat(
NumberFormats.TEXT);
Label labelText = new Label(0, 3, "010-12345", contentFromart);
ws.addCell(labelText);
// 输出流
wwb.write();
// 关闭流
wwb.close();