From 56da04fa6a7adbf8c7303c9fc1fac9a263c64ee7 Mon Sep 17 00:00:00 2001 From: lzp <3490642276@qq.com> Date: Mon, 17 Jun 2024 14:06:14 +0800 Subject: [PATCH] test --- src/com/excel/AccidentExcelsss.java | 53 ++++++++++++++++++++++++++ src/com/excel/CallExcelsss.java | 52 +++++++++++++++++++++++++ src/com/excel/CarExcelldy.java | 51 +++++++++++++++++++++++++ src/com/excel/DepartmentExcelldy.java | 51 +++++++++++++++++++++++++ src/com/excel/EmployeeExcellzp.java | 52 +++++++++++++++++++++++++ src/com/excel/RepairExcellzp.java | 55 +++++++++++++++++++++++++++ 6 files changed, 314 insertions(+) create mode 100644 src/com/excel/AccidentExcelsss.java create mode 100644 src/com/excel/CallExcelsss.java create mode 100644 src/com/excel/CarExcelldy.java create mode 100644 src/com/excel/DepartmentExcelldy.java create mode 100644 src/com/excel/EmployeeExcellzp.java create mode 100644 src/com/excel/RepairExcellzp.java diff --git a/src/com/excel/AccidentExcelsss.java b/src/com/excel/AccidentExcelsss.java new file mode 100644 index 0000000..de25631 --- /dev/null +++ b/src/com/excel/AccidentExcelsss.java @@ -0,0 +1,53 @@ + +package com.zlsl.excel; +import com.zlsl.dao.impl.*; +import com.zlsl.javaBean.*; +import jxl.Workbook; +import jxl.format.Colour; +import jxl.write.*; + +import java.io.File; +import java.util.List; + +import com.zlsl.dao.impl.AccidentsssImpl; +import com.zlsl.javaBean.Accidentsss; + +public class AccidentExcelsss { + + + + + public static void excelExport() throws Exception { + File file = new File("D:\\accident.xls"); + if (!file.exists()) {//如果不存在则创建该文件 + file.getParentFile().mkdirs(); + } + WritableWorkbook wb = Workbook.createWorkbook(file);//创建新工作簿 + WritableSheet wsheet = wb.createSheet("事故记录", 0);// 创建sheet表 + //设置表头 + String[] columnNames = {"id", "发生时间", "发生地点", "事故类型","严重等级","负责人工号","车辆ID"}; + WritableFont wFontTitle = new WritableFont(WritableFont.createFont("宋体"), 14); + WritableCellFormat fontTitle = new WritableCellFormat(wFontTitle); + fontTitle.setBackground(Colour.SKY_BLUE);//设置单元格背景色 + for (int i = 0; i < columnNames.length; i++) { + wsheet.addCell(new Label(i, 0, columnNames[i], fontTitle)); + } + //字体 + WritableFont wFont = new WritableFont(WritableFont.createFont("宋体"), 14); + WritableCellFormat font = new WritableCellFormat(wFont); + List accidentList =AccidentsssImpl.selectAll(); + // 把数据写入工作部中 + for (int i = 0; i < accidentList.size(); i++) { + wsheet.addCell(new Label(0, i + 1, accidentList.get(i).getId()+"", font)); + wsheet.addCell(new Label(1, i + 1, accidentList.get(i).getDate_time(), font)); + wsheet.addCell(new Label(2, i + 1, accidentList.get(i).getLocation(), font)); + wsheet.addCell(new Label(3, i + 1, accidentList.get(i).getAccident_type() , font)); + wsheet.addCell(new Label(4, i + 1, accidentList.get(i).getAccident_level() + "", font)); + + } + wb.write(); + wb.close(); + System.out.println("输出完成!"); + } + +} diff --git a/src/com/excel/CallExcelsss.java b/src/com/excel/CallExcelsss.java new file mode 100644 index 0000000..4f628d4 --- /dev/null +++ b/src/com/excel/CallExcelsss.java @@ -0,0 +1,52 @@ + +package com.zlsl.excel; +import com.zlsl.dao.impl.*; +import com.zlsl.javaBean.*; +import jxl.Workbook; +import jxl.format.Colour; +import jxl.write.*; + +import java.io.File; +import java.util.List; + +public class CallExcelsss { + + + + + public static void excelExport() throws Exception { + File file = new File("D:\\Call.xls"); + if (!file.exists()) {//如果不存在则创建该文件 + file.getParentFile().mkdirs(); + } + WritableWorkbook wb = Workbook.createWorkbook(file);//创建新工作簿 + WritableSheet wsheet = wb.createSheet("车辆调用信息", 0);// 创建sheet表 + //设置表头 + String[] columnNames = {"id", "调用人工号", "调用车辆id", "调用时间", "是否归还"}; + WritableFont wFontTitle = new WritableFont(WritableFont.createFont("宋体"), 14); + WritableCellFormat fontTitle = new WritableCellFormat(wFontTitle); + fontTitle.setBackground(Colour.SKY_BLUE);//设置单元格背景色 + for (int i = 0; i < columnNames.length; i++) { + wsheet.addCell(new Label(i, 0, columnNames[i], fontTitle)); + } + //字体 + WritableFont wFont = new WritableFont(WritableFont.createFont("宋体"), 14); + WritableCellFormat font = new WritableCellFormat(wFont); + List callList = CallsssImpl.selectAll(); + // 把数据写入工作部中 + for (int i = 0; i < callList.size(); i++) { + wsheet.addCell(new Label(0, i + 1, callList.get(i).getId()+"", font)); + wsheet.addCell(new Label(1, i + 1, callList.get(i).getResponsible(), font)); + wsheet.addCell(new Label(2, i + 1, callList.get(i).getCar_id()+ "", font)); + wsheet.addCell(new Label(3, i + 1, callList.get(i).getDate_time() + "", font)); + wsheet.addCell(new Label(4, i + 1, callList.get(i).getIs_return(), font)); + + } + wb.write(); + wb.close(); + System.out.println("输出完成!"); + } + +} + + diff --git a/src/com/excel/CarExcelldy.java b/src/com/excel/CarExcelldy.java new file mode 100644 index 0000000..352dd9a --- /dev/null +++ b/src/com/excel/CarExcelldy.java @@ -0,0 +1,51 @@ + +package com.zlsl.excel; +import com.zlsl.dao.impl.*; +import com.zlsl.javaBean.*; +import jxl.write.*; +import jxl.Workbook; +import jxl.format.Colour; +import jxl.write.*; + +import java.io.File; +import java.util.List; + +public class CarExcelldy { + + + + + public static void excelExport() throws Exception { + File file = new File("D:\\car.xls"); + if (!file.exists()) {//如果不存在则创建该文件 + file.getParentFile().mkdirs(); + } + WritableWorkbook wb = Workbook.createWorkbook(file);//创建新工作簿 + WritableSheet wsheet = wb.createSheet("车辆信息", 0);// 创建sheet表 + //设置表头 + String[] columnNames = {"id", "车牌号", "车型", "车龄", "颜色", "是否闲置"}; + WritableFont wFontTitle = new WritableFont(WritableFont.createFont("宋体"), 14); + WritableCellFormat fontTitle = new WritableCellFormat(wFontTitle); + fontTitle.setBackground(Colour.SKY_BLUE);//设置单元格背景色 + for (int i = 0; i < columnNames.length; i++) { + wsheet.addCell(new Label(i, 0, columnNames[i], fontTitle)); + } + //字体 + WritableFont wFont = new WritableFont(WritableFont.createFont("宋体"), 14); + WritableCellFormat font = new WritableCellFormat(wFont); + List carList = CarldyImpl.selectAll(); + // 把数据写入工作部中 + for (int i = 0; i < carList.size(); i++) { + wsheet.addCell(new Label(0, i + 1, carList.get(i).getId()+"", font)); + wsheet.addCell(new Label(1, i + 1, carList.get(i).getCar_number(), font)); + wsheet.addCell(new Label(2, i + 1, carList.get(i).getModel(), font)); + wsheet.addCell(new Label(3, i + 1, carList.get(i).getCar_age() + "", font)); + wsheet.addCell(new Label(4, i + 1, carList.get(i).getColor(), font)); + wsheet.addCell(new Label(5, i + 1, carList.get(i).getIs_unused()+"", font)); + } + wb.write(); + wb.close(); + System.out.println("输出完成!"); + } + +} diff --git a/src/com/excel/DepartmentExcelldy.java b/src/com/excel/DepartmentExcelldy.java new file mode 100644 index 0000000..b599495 --- /dev/null +++ b/src/com/excel/DepartmentExcelldy.java @@ -0,0 +1,51 @@ + +package com.zlsl.excel; +import com.zlsl.dao.impl.*; +import com.zlsl.javaBean.*; +import jxl.Workbook; +import jxl.format.Colour; +import jxl.write.*; + +import java.io.File; +import java.util.List; + +import com.zlsl.dao.impl.DepartmentldyImpl; +import com.zlsl.javaBean.Departmentldy; + +public class DepartmentExcelldy { + + + + + public static void excelExport() throws Exception { + File file = new File("D:\\department.xls"); + if (!file.exists()) {//如果不存在则创建该文件 + file.getParentFile().mkdirs(); + } + WritableWorkbook wb = Workbook.createWorkbook(file);//创建新工作簿 + WritableSheet wsheet = wb.createSheet("部门信息", 0);// 创建sheet表 + //设置表头 + String[] columnNames = {"id", "部门名称", "主管人工号", "部门电话"}; + WritableFont wFontTitle = new WritableFont(WritableFont.createFont("宋体"), 14); + WritableCellFormat fontTitle = new WritableCellFormat(wFontTitle); + fontTitle.setBackground(Colour.SKY_BLUE);//设置单元格背景色 + for (int i = 0; i < columnNames.length; i++) { + wsheet.addCell(new Label(i, 0, columnNames[i], fontTitle)); + } + //字体 + WritableFont wFont = new WritableFont(WritableFont.createFont("宋体"), 14); + WritableCellFormat font = new WritableCellFormat(wFont); + List departmentList =DepartmentldyImpl.selectAll(); + // 把数据写入工作部中 + for (int i = 0; i < departmentList.size(); i++) { + wsheet.addCell(new Label(0, i + 1, departmentList.get(i).getId()+"", font)); + wsheet.addCell(new Label(1, i + 1, departmentList.get(i).getName(), font)); + wsheet.addCell(new Label(2, i + 1, departmentList.get(i).getManager_num(), font)); + wsheet.addCell(new Label(3, i + 1, departmentList.get(i).getTelephone() + "", font)); + } + wb.write(); + wb.close(); + System.out.println("输出完成!"); + } + +} diff --git a/src/com/excel/EmployeeExcellzp.java b/src/com/excel/EmployeeExcellzp.java new file mode 100644 index 0000000..887390a --- /dev/null +++ b/src/com/excel/EmployeeExcellzp.java @@ -0,0 +1,52 @@ + +package com.zlsl.excel; + +import com.zlsl.dao.*; +import com.zlsl.dao.impl.EmployeeImpllzp; +import com.zlsl.javaBean.*; +import jxl.Workbook; +import jxl.format.Colour; +import jxl.write.*; + +import java.io.File; +import java.util.List; + + +public class EmployeeExcellzp { + + public static void excelExport() throws Exception { + File file = new File("D:\\employee.xls"); + if (!file.exists()) {//如果不存在则创建该文件 + file.getParentFile().mkdirs(); + } + WritableWorkbook wb = Workbook.createWorkbook(file);//创建新工作簿 + WritableSheet wsheet = wb.createSheet("员工信息", 0);// 创建sheet表 + //设置表头 + String[] columnNames = {"id", "员工姓名", "身份证号", "电话号码", "职位", "工龄","部门id"}; + WritableFont wFontTitle = new WritableFont(WritableFont.createFont("宋体"), 14); + WritableCellFormat fontTitle = new WritableCellFormat(wFontTitle); + fontTitle.setBackground(Colour.SKY_BLUE);//设置单元格背景色 + for (int i = 0; i < columnNames.length; i++) { + wsheet.addCell(new Label(i, 0, columnNames[i], fontTitle)); + } + //字体 + WritableFont wFont = new WritableFont(WritableFont.createFont("宋体"), 14); + WritableCellFormat font = new WritableCellFormat(wFont); + List employeeList = EmployeeImpllzp.selectAll(); + // 把数据写入工作部中 + for (int i = 0; i < employeeList.size(); i++) { + wsheet.addCell(new Label(0, i + 1, employeeList.get(i).getNumber(), font)); + wsheet.addCell(new Label(1, i + 1, employeeList.get(i).getName(), font)); + wsheet.addCell(new Label(2, i + 1, employeeList.get(i).getIDCard(), font)); + wsheet.addCell(new Label(3, i + 1, employeeList.get(i).getPhone() + "", font)); + wsheet.addCell(new Label(4, i + 1, employeeList.get(i).getPosition(), font)); + wsheet.addCell(new Label(5, i + 1, employeeList.get(i).getSeniority(), font)); + wsheet.addCell(new Label(6, i + 1, employeeList.get(i).getDep_id()+"", font)); + } + wb.write(); + wb.close(); + System.out.println("输出完成!"); + } + +} + diff --git a/src/com/excel/RepairExcellzp.java b/src/com/excel/RepairExcellzp.java new file mode 100644 index 0000000..7246789 --- /dev/null +++ b/src/com/excel/RepairExcellzp.java @@ -0,0 +1,55 @@ + +package com.zlsl.excel; + +import com.zlsl.dao.*; +import com.zlsl.dao.impl.EmployeeImpllzp; +import com.zlsl.dao.impl.RepairImpllzp; +import com.zlsl.javaBean.*; +import jxl.Workbook; +import jxl.format.Colour; +import jxl.write.*; + +import java.io.File; +import java.util.List; + +/** + * + */ +public class RepairExcellzp { + + public static void excelExport() throws Exception { + File file = new File("D:\\repair.xls"); + if (!file.exists()) {//如果不存在则创建该文件 + file.getParentFile().mkdirs(); + } + WritableWorkbook wb = Workbook.createWorkbook(file);//创建新工作簿 + WritableSheet wsheet = wb.createSheet("维修信息", 0);// 创建sheet表 + //设置表头 + String[] columnNames = {"id", "时间", "维修地址", "维修项目", "费用", "负责人工号","车辆ID"}; + WritableFont wFontTitle = new WritableFont(WritableFont.createFont("宋体"), 14); + WritableCellFormat fontTitle = new WritableCellFormat(wFontTitle); + fontTitle.setBackground(Colour.SKY_BLUE);//设置单元格背景色 + for (int i = 0; i < columnNames.length; i++) { + wsheet.addCell(new Label(i, 0, columnNames[i], fontTitle)); + } + //字体 + WritableFont wFont = new WritableFont(WritableFont.createFont("宋体"), 14); + WritableCellFormat font = new WritableCellFormat(wFont); + List repairList = RepairImpllzp.selectAll(); + // 把数据写入工作部中 + for (int i = 0; i < repairList.size(); i++) { + wsheet.addCell(new Label(0, i + 1, repairList.get(i).getId() +"", font)); + wsheet.addCell(new Label(1, i + 1, repairList.get(i).getDate_time(), font)); + wsheet.addCell(new Label(2, i + 1, repairList.get(i).getRepair_address(), font)); + wsheet.addCell(new Label(3, i + 1, repairList.get(i).getRepair_project() + "", font)); + wsheet.addCell(new Label(4, i + 1, repairList.get(i).getCost() +"",font)); + wsheet.addCell(new Label(5, i + 1, repairList.get(i).getResponsible(), font)); + wsheet.addCell(new Label(6, i + 1, repairList.get(i).getCar_id()+"", font)); + } + wb.write(); + wb.close(); + System.out.println("输出完成!"); + } + +} +