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;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
java毕业设计-基于SSM的汽车租赁管理系统源码+数据库(高分项目).zip
共307个文件
java:80个
gif:75个
js:44个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 3 下载量 108 浏览量
2023-05-30
15:23:05
上传
评论 2
收藏 1.33MB ZIP 举报
温馨提示
java毕业设计—基于SSM的汽车租赁管理系统源码+数据库(高分项目).zip 代码完整下载可用,纯手打高分项目,也可作为期末大作业和课程设计。 java毕业设计—基于SSM的汽车租赁管理系统源码+数据库(高分项目).zip 代码完整下载可用,纯手打高分项目,也可作为期末大作业和课程设计。java毕业设计—基于SSM的汽车租赁管理系统源码+数据库(高分项目).zip 代码完整下载可用,纯手打高分项目,也可作为期末大作业和课程设计。java毕业设计—基于SSM的汽车租赁管理系统源码+数据库(高分项目).zip 代码完整下载可用,纯手打高分项目,也可作为期末大作业和课程设计。java毕业设计—基于SSM的汽车租赁管理系统源码+数据库(高分项目).zip 代码完整下载可用,纯手打高分项目,也可作为期末大作业和课程设计。java毕业设计—基于SSM的汽车租赁管理系统源码+数据库(高分项目).zip 代码完整下载可用,纯手打高分项目,也可作为期末大作业和课程设计。java毕业设计—基于SSM的汽车租赁管理系统源码+数据库(高分项目).zip 代码完整下载可用,纯手打高分项目,也
资源推荐
资源详情
资源评论
收起资源包目录
java毕业设计-基于SSM的汽车租赁管理系统源码+数据库(高分项目).zip (307个子文件)
layui.css 91KB
layer.css 14KB
public.css 12KB
index.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 509B
bodyTabDoc.html 13KB
index.html 10KB
userInfo.html 5KB
newsAdd.html 4KB
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
共 307 条
- 1
- 2
- 3
- 4
资源评论
- 兽兽鸭.2023-11-24资源内容总结地很全面,值得借鉴,对我来说很有用,解决了我的燃眉之急。
- weixin_590569402024-01-11资源很好用,有较大的参考价值,资源不错,支持一下。
- weixin_541632412024-03-16简直是宝藏资源,实用价值很高,支持!
盈梓的博客
- 粉丝: 6839
- 资源: 1245
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 使用 C 语言实现的计算非负整数的阶乘
- 2011-2021最新版本北京大学数字普惠金融指数(PKU-DFIIC).xlsx
- 县域数字乡村指数2018-2020(1).xlsx
- Docker容器配置进阶
- tensorflow-gpu-2.7.4-cp37-cp37m-manylinux2010-x86-64.whl
- 多段线、 圆、弧转多段线(仅我可见)
- tensorflow-2.7.2-cp38-cp38-manylinux2010-x86-64.whl
- 李慧琴C语言基础部分.zip
- yeyue-p8Yi4-ve4a83792.apk
- tensorflow-gpu-2.7.3-cp38-cp38-manylinux2010-x86-64.whl
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功