package com.bjpowernode.stat.utils;
import com.bjpowernode.bus.domain.Customer;
import com.bjpowernode.bus.domain.Rent;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.ClientAnchor;
import org.apache.poi.ss.util.CellRangeAddress;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
/**
* 出租单数据库导出
*/
public class ExportRentUtils {
/**
* 导出出租单的数据
* @param rent
* @param sheetName
* @param customer
* @return
*/
public static ByteArrayOutputStream exportRent(Rent rent, Customer customer, String sheetName) {
//1.组装excel文档
//1.1创建工作簿
HSSFWorkbook workbook = new HSSFWorkbook();
//1.2创建样式
HSSFCellStyle baseStyle = ExportHSSFCellStyle.createBaseStyle(workbook);
HSSFCellStyle titleStyle = ExportHSSFCellStyle.createTitleStyle(workbook);
//1.3在工作簿创建sheet
HSSFSheet sheet = workbook.createSheet(sheetName);
//1.4设置sheet
sheet.setDefaultColumnWidth(30);
sheet.setColumnWidth(1,50*256);
//1.5合并
CellRangeAddress region1 = new CellRangeAddress(0, 0, 0, 3);
sheet.addMergedRegion(region1);
//1.6.1创建第一行
int index=0;
HSSFRow row1 = sheet.createRow(index);
//1.6.2在第一行里面创建一个单元格
HSSFCell row1_cell1 = row1.createCell(0);
//1.6.3设置标题样式
row1_cell1.setCellStyle(titleStyle);
//1.6.4设置单元格内容
row1_cell1.setCellValue(customer.getCustname()+"的出租单信息");
//1.7.1创建第二行
index++;
HSSFRow row2 = sheet.createRow(index);
//设置行高
row2.setHeightInPoints(150);
HSSFCell row2_cell1 = row2.createCell(0);
row2_cell1.setCellStyle(baseStyle);
row2_cell1.setCellValue("出租单号:");
HSSFCell row2_cell2 = row2.createCell(1);
row2_cell2.setCellStyle(baseStyle);
row2_cell2.setCellValue(rent.getRentid());
HSSFCell row2_cell3 = row2.createCell(2);
row2_cell3.setCellStyle(baseStyle);
row2_cell3.setCellValue("二维码:");
HSSFCell row2_cell4 = row2.createCell(3);
row2_cell4.setCellStyle(baseStyle);
row2_cell4.setCellValue("");
InputStream logoStream = ExportCustomerUtils.class.getClassLoader().getResourceAsStream("logo.jpg");
//画图片
BufferedImage image = ZXingCodeEncodeUtils.createZxingCodeUseLogo(rent.getRentid(), 150, 150, logoStream);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
ImageIO.write(image,"JPEG",bos);
} catch (IOException e) {
e.printStackTrace();
}
//画图的顶级管理器,一个sheet只能获取一个
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
/**
* 参数4 设置图片的平铺程度 最大值是255 255代表铺满当前单元格 小于255就铺不满
* 参数5 列的开始坐标
* 参数6 行的开始坐标
* 参数7 列的结束坐标
* 参数8 行的结束坐标
*/
HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 255, (short) 3, 1, (short) 4, 1);
anchor.setAnchorType(ClientAnchor.AnchorType.DONT_MOVE_AND_RESIZE);
patriarch.createPicture(anchor,workbook.addPicture(bos.toByteArray(),HSSFWorkbook.PICTURE_TYPE_JPEG));
//1.7.1创建第三行
index++;
HSSFRow row3 = sheet.createRow(index);
HSSFCell row3_cell1 = row3.createCell(0);
row3_cell1.setCellStyle(baseStyle);
row3_cell1.setCellValue("客户姓名:");
HSSFCell row3_cell2 = row3.createCell(1);
row3_cell2.setCellStyle(baseStyle);
row3_cell2.setCellValue(customer.getCustname());
HSSFCell row3_cell3 = row3.createCell(2);
row3_cell3.setCellStyle(baseStyle);
row3_cell3.setCellValue("身份证号:");
HSSFCell row3_cell4 = row3.createCell(3);
row3_cell4.setCellStyle(baseStyle);
row3_cell4.setCellValue(customer.getIdentity());
//1.7.1创建第四行
index++;
HSSFRow row4 = sheet.createRow(index);
HSSFCell row4_cell1 = row4.createCell(0);
row4_cell1.setCellStyle(baseStyle);
row4_cell1.setCellValue("起租时间");
HSSFCell row4_cell2 = row4.createCell(1);
row4_cell2.setCellStyle(baseStyle);
row4_cell2.setCellValue(rent.getBegindate().toLocaleString());
HSSFCell row4_cell3 = row4.createCell(2);
row4_cell3.setCellStyle(baseStyle);
row4_cell3.setCellValue("还车时间:");
HSSFCell row4_cell4 = row4.createCell(3);
row4_cell4.setCellStyle(baseStyle);
row4_cell4.setCellValue(rent.getReturndate().toLocaleString());
//1.7.1创建第三行
index++;
HSSFRow row5 = sheet.createRow(index);
HSSFCell row5_cell1 = row5.createCell(0);
row5_cell1.setCellStyle(baseStyle);
row5_cell1.setCellValue("车牌号:");
HSSFCell row5_cell2 = row5.createCell(1);
row5_cell2.setCellStyle(baseStyle);
row5_cell2.setCellValue(rent.getCarnumber());
HSSFCell row5_cell3 = row5.createCell(2);
row5_cell3.setCellStyle(baseStyle);
row5_cell3.setCellValue("出租价格:");
HSSFCell row5_cell4 = row5.createCell(3);
row5_cell4.setCellStyle(baseStyle);
row5_cell4.setCellValue(rent.getPrice());
//第六行 - 空行
index++;
//第七行
index++;
HSSFRow row7 = sheet.createRow(index);
HSSFCell row7_cell3 = row7.createCell(2);
row7_cell3.setCellStyle(baseStyle);
row7_cell3.setCellValue("打印时间:");
HSSFCell row7_cell4 = row7.createCell(3);
row7_cell4.setCellStyle(baseStyle);
row7_cell4.setCellValue(new Date().toLocaleString());
//第八行
index++;
HSSFRow row8 = sheet.createRow(index);
HSSFCell row8_cell3 = row8.createCell(2);
row8_cell3.setCellStyle(baseStyle);
row8_cell3.setCellValue("操作员:");
HSSFCell row8_cell4 = row8.createCell(3);
row8_cell4.setCellStyle(baseStyle);
row8_cell4.setCellValue(rent.getOpername());
//第九行
index++;
HSSFRow row9 = sheet.createRow(index);
HSSFCell row9_cell3 = row9.createCell(2);
row9_cell3.setCellStyle(baseStyle);
row9_cell3.setCellValue("客户签名:");
//到此excel组装完毕
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
//把workbook里面的数据写到outputStream
try {
workbook.write(outputStream);
} catch (IOException e) {
e.printStackTrace();
}
return outputStream;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
免费送你项目资料啦:基于layui的汽车租赁项目(免费提供源码)
共316个文件
java:80个
gif:75个
js:44个
需积分: 0 1 下载量 16 浏览量
2024-04-30
11:48:19
上传
评论
收藏 1.41MB ZIP 举报
温馨提示
. 项目背景: 项目发起背景: 我们团队在意识到现代社会对于汽车租赁服务的需求不断增长的基础上,决定开展汽车租赁项目。随着城市化进程的不断加快,越来越多的人更倾向于灵活、便捷的出行方式,而汽车租赁服务正是满足这一需求的理想选择。 项目目的: 该项目旨在构建一个基于layui前端框架的汽车租赁平台,为用户提供方便快捷的汽车租赁服务。通过该平台,用户可以轻松预订、租赁汽车,并享受便捷的用车体验。 实施情况: 经过团队的共同努力,我们已经完成了项目的开发,并且准备向团队内外分享这个项目的详细信息,以期得到更多反馈和改进意见。 2. 模块: 用户管理模块: 包括用户注册、登录、个人信息管理等功能。 车辆管理模块: 用于管理汽车信息,包括添加、编辑、删除汽车信息等功能。 订单管理模块: 用于管理用户的订单信息,包括订单查询、订单取消等功能。 权限管理模块: 用于管理用户的权限,包括管理员权限和普通用户权限等。 支付管理模块: 用于处理用户的支付流程,包括支付方式选择、支付状态查询等功能。
资源推荐
资源详情
资源评论
收起资源包目录
免费送你项目资料啦:基于layui的汽车租赁项目(免费提供源码) (316个子文件)
layui.css 96KB
layer.css 14KB
index.css 13KB
public.css 12KB
layui.mobile.css 10KB
laydate.css 7KB
dtree.css 5KB
dtreefont.css 4KB
code.css 1KB
iconfont.eot 41KB
dtreefont.eot 19KB
59.gif 10KB
22.gif 10KB
24.gif 8KB
13.gif 7KB
16.gif 7KB
39.gif 6KB
64.gif 6KB
63.gif 6KB
50.gif 6KB
loading-0.gif 6KB
4.gif 6KB
1.gif 5KB
42.gif 5KB
71.gif 5KB
21.gif 5KB
20.gif 5KB
29.gif 5KB
70.gif 4KB
5.gif 4KB
17.gif 4KB
27.gif 4KB
9.gif 4KB
44.gif 4KB
11.gif 4KB
8.gif 4KB
3.gif 4KB
23.gif 4KB
34.gif 4KB
41.gif 4KB
38.gif 4KB
65.gif 3KB
32.gif 3KB
45.gif 3KB
7.gif 3KB
12.gif 3KB
26.gif 3KB
60.gif 3KB
2.gif 3KB
40.gif 3KB
25.gif 3KB
19.gif 3KB
66.gif 3KB
18.gif 3KB
46.gif 3KB
10.gif 3KB
28.gif 3KB
51.gif 3KB
57.gif 3KB
67.gif 3KB
0.gif 3KB
48.gif 3KB
43.gif 3KB
30.gif 2KB
61.gif 2KB
33.gif 2KB
69.gif 2KB
14.gif 2KB
47.gif 2KB
36.gif 2KB
49.gif 2KB
58.gif 2KB
6.gif 2KB
54.gif 2KB
53.gif 2KB
56.gif 2KB
62.gif 2KB
31.gif 2KB
55.gif 2KB
35.gif 2KB
15.gif 2KB
loading-2.gif 2KB
37.gif 1KB
68.gif 1KB
52.gif 777B
loading-1.gif 701B
.gitignore 545B
bodyTabDoc.html 13KB
index.html 11KB
userInfo.html 5KB
newsAdd.html 5KB
addressDoc.html 4KB
basicParameter.html 4KB
navDoc.html 3KB
userAdd.html 3KB
changePwd.html 2KB
login.html 2KB
userGrade.html 2KB
linksAdd.html 2KB
newsList.html 2KB
共 316 条
- 1
- 2
- 3
- 4
资源评论
阿吉的呓语
- 粉丝: 1213
- 资源: 121
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- [大模型部署]在C# Winform中使用文心一言ERNIE-3.5 4K 聊天模型
- python毕业设计-基于Django+OpenCV的二维码生成与识别系统设计与实现.zip
- python毕业设计-基于Django+OpenCV的二维码生成与识别系统设计与实现+使用说明.zip
- 基于STM32单片机空气监测系统设计源码+详细文档+配套全部资料(毕业设计).zip
- rdf0412-kcu116-pcie-c-2019-1.zip(XILINX KCU116 源码)
- 基于C#语言的winform界面火车票订票系统(源码+实验报告)
- 【华为OD部分真题及讲解】华为OD部分真题及讲解
- 基于Python+Django的京东商品比价系统源码+全部资料(毕业设计).zip
- G460 G560 Z460 Z560的最新BIOS 2.18版(无白名单)
- MetaJUI v0.4
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功