|
@@ -7,10 +7,59 @@ import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
|
|
import java.io.FileInputStream;
|
|
|
+import java.io.FileNotFoundException;
|
|
|
+import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
|
|
|
public class ExecelAction {
|
|
|
public static void main(String[] args) throws IOException {
|
|
|
+ execelExport();
|
|
|
+ }
|
|
|
+ private static void execelExport() throws IOException {
|
|
|
+ /**
|
|
|
+ * 数据库内的数据
|
|
|
+ * 需求方比较着急, 直接在工具里面导出了 临时性的一次性的
|
|
|
+ * 长期需求, 打卡记录 OA系统, 财务每个月计算工资, 打卡记录
|
|
|
+ */
|
|
|
+ //创建execel对象
|
|
|
+ XSSFWorkbook sheets = new XSSFWorkbook();
|
|
|
+ //创建sheet页面
|
|
|
+ XSSFSheet sheet = sheets.createSheet("打卡记录");
|
|
|
+
|
|
|
+ XSSFRow row = sheet.createRow(0);
|
|
|
+ row.createCell(0).setCellValue("周一");
|
|
|
+ row.createCell(1).setCellValue("周二");
|
|
|
+ row.createCell(2).setCellValue("周三");
|
|
|
+ row.createCell(3).setCellValue("周四");
|
|
|
+ row.createCell(4).setCellValue("周五");
|
|
|
+ row.createCell(5).setCellValue("周六");
|
|
|
+
|
|
|
+ XSSFRow row1 = sheet.createRow(1);
|
|
|
+ row1.createCell(0).setCellValue("08:31");
|
|
|
+ row1.createCell(1).setCellValue("08:21");
|
|
|
+ row1.createCell(2).setCellValue("08:11");
|
|
|
+ row1.createCell(3).setCellValue("08:31");
|
|
|
+ row1.createCell(4).setCellValue("08:51");
|
|
|
+ row1.createCell(5).setCellValue("08:42");
|
|
|
+
|
|
|
+ XSSFRow row2 = sheet.createRow(2);
|
|
|
+ row2.createCell(0).setCellValue("08:42");
|
|
|
+ row2.createCell(1).setCellValue("08:43");
|
|
|
+ row2.createCell(2).setCellValue("08:44");
|
|
|
+ row2.createCell(3).setCellValue("08:45");
|
|
|
+ row2.createCell(4).setCellValue("08:46");
|
|
|
+ row2.createCell(5).setCellValue("08:47");
|
|
|
+
|
|
|
+ String path = "day15/demo1.xlsx";
|
|
|
+ FileOutputStream fileInputStream = new FileOutputStream(path);
|
|
|
+
|
|
|
+ sheets.write( fileInputStream );
|
|
|
+ fileInputStream.close();
|
|
|
+
|
|
|
+ //向用户输出下载请求
|
|
|
+
|
|
|
+ }
|
|
|
+ private static void execelImport() throws IOException {
|
|
|
//我们表格文件存储地址
|
|
|
String path = "day15/demo.xlsx";
|
|
|
//我们创建一个表格的文件流
|
|
@@ -41,3 +90,4 @@ public class ExecelAction {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|