复杂excel导出,涉及到横向、纵向单元格合并,指定单元格格式,显示边框等
java
public Object exportExcelDay(Long marketId, String startDate, String endDate) {
//生成excel
String sheetName = startDate + "日报表统计.xlsx";
//创建sheet页
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet(sheetName);
sheet.setDefaultColumnWidth(20);
// 合并单元格
CellRangeAddress region = new CellRangeAddress(0, 0, 0, 6);//标题
CellRangeAddress region11 = new CellRangeAddress(1, 1, 1, 4);//市场名称
CellRangeAddress region12 = new CellRangeAddress(1, 1, 5, 6);//日期
CellRangeAddress region22 = new CellRangeAddress(2, 2, 2, 4);//本日
CellRangeAddress region23 = new CellRangeAddress(2, 2, 5, 6);//本月累计
sheet.addMergedRegion(region);
sheet.addMergedRegion(region11);
sheet.addMergedRegion(region12);
sheet.addMergedRegion(region22);
sheet.addMergedRegion(region23);
//单元格风格
HorizontalAlignment hACenter = HorizontalAlignment.CENTER;//水平居中
HorizontalAlignment hARight = HorizontalAlignment.RIGHT;//水平居右
HorizontalAlignment hALeft = HorizontalAlignment.LEFT;//水平居左
VerticalAlignment vACenter = VerticalAlignment.CENTER;//垂直居中
// VerticalAlignment vATop = VerticalAlignment.TOP;//垂直居上
// VerticalAlignment vABottom = VerticalAlignment.BOTTOM;//垂直居下
CellStyle styleCenter = workbook.createCellStyle();
styleCenter.setAlignment(hACenter);
styleCenter.setVerticalAlignment(vACenter);
CellStyle styleRight = workbook.createCellStyle();
styleRight.setAlignment(hARight);
styleRight.setVerticalAlignment(vACenter);
CellStyle styleLeft = workbook.createCellStyle();
styleLeft.setAlignment(hALeft);
styleLeft.setVerticalAlignment(vACenter);
//创建表头(第一行)
XSSFRow row = sheet.createRow(0);
XSSFCell cell = row.createCell(0);
cell.setCellValue("交易情况日报表");
cell.setCellStyle(styleCenter);
XSSFRow row1 = sheet.createRow(1);
XSSFCell cell10 = row1.createCell(0);
cell10.setCellStyle(styleCenter);
cell10.setCellValue("项 目");
XSSFCell cell11 = row1.createCell(1);
cell11.setCellStyle(styleCenter);
cell11.setCellValue("sysDept.getDeptName()");
XSSFCell cell12 = row1.createCell(5);
cell12.setCellStyle(styleRight);
cell12.setCellValue("填报日期:"+startDate);
XSSFRow row2 = sheet.createRow(2);
XSSFCell cell20 = row2.createCell(0);
cell20.setCellStyle(styleLeft);
cell20.setCellValue("一、交易情况");
XSSFCell cell21 = row2.createCell(1);
cell21.setCellStyle(styleCenter);
cell21.setCellValue("单位");
XSSFCell cell22 = row2.createCell(2);
cell22.setCellStyle(styleCenter);
cell22.setCellValue("本日");
XSSFCell cell23 = row2.createCell(5);
cell23.setCellStyle(styleCenter);
cell23.setCellValue("本月累计");
XSSFRow row3 = sheet.createRow(3);
XSSFCell cell30 = row3.createCell(0);
cell30.setCellStyle(styleLeft);
cell30.setCellValue("1、交易数量");
XSSFCell cell31 = row3.createCell(1);
cell31.setCellStyle(styleCenter);
cell31.setCellValue("斤");
XSSFCell cell32 = row3.createCell(2);
cell32.setCellStyle(styleCenter);
cell32.setCellValue("100616");
CellRangeAddress region324 = new CellRangeAddress(3, 3, 2, 4);//本日
sheet.addMergedRegion(region324);
XSSFCell cell33 = row3.createCell(5);
cell33.setCellStyle(styleCenter);
cell33.setCellValue("1761488");
CellRangeAddress region33 = new CellRangeAddress(3, 3, 5, 6);//本月累计
sheet.addMergedRegion(region33);
int rowNum = 0;
for (int i = 0; i < 2; i++) {
XSSFRow row4 = sheet.createRow(i+4);
XSSFCell cell40 = row4.createCell(0);
cell40.setCellStyle(styleCenter);
cell40.setCellValue("其中:("+(i+1)+")"+"黄瓜"+i);
XSSFCell cell41 = row4.createCell(1);
cell41.setCellStyle(styleRight);
cell41.setCellValue("斤");
XSSFCell cell42 = row4.createCell(2);
cell42.setCellStyle(styleCenter);
cell42.setCellValue("100616");
CellRangeAddress region424 = new CellRangeAddress(i+4, i+4, 2, 4);//本日
sheet.addMergedRegion(region424);
XSSFCell cell43 = row4.createCell(5);
cell43.setCellStyle(styleCenter);
cell43.setCellValue("1761488");
CellRangeAddress region44 = new CellRangeAddress(i+4, i+4, 5, 6);//本月累计
sheet.addMergedRegion(region44);
rowNum = i+4;
}
rowNum = rowNum+1;
XSSFRow row5 = sheet.createRow(rowNum);
XSSFCell cell50 = row5.createCell(0);
cell50.setCellStyle(styleLeft);
cell50.setCellValue("2、服务费标准");
XSSFCell cell51 = row5.createCell(1);
cell51.setCellStyle(styleCenter);
cell51.setCellValue("元/斤");
XSSFCell cell52 = row5.createCell(2);
cell52.setCellStyle(styleCenter);
cell52.setCellValue("0.06");
CellRangeAddress region524 = new CellRangeAddress(rowNum, rowNum, 2, 4);//本日
sheet.addMergedRegion(region524);
XSSFCell cell53 = row5.createCell(5);
cell53.setCellStyle(styleCenter);
cell53.setCellValue("0.06");
CellRangeAddress region55 = new CellRangeAddress(rowNum, rowNum, 5, 6);//本月累计
sheet.addMergedRegion(region55);
XSSFRow row6 = sheet.createRow(rowNum+1);
XSSFCell cell60 = row6.createCell(0);
cell60.setCellStyle(styleLeft);
cell60.setCellValue("3、交易价格");
XSSFCell cell61 = row6.createCell(1);
cell61.setCellStyle(styleCenter);
cell61.setCellValue("元/斤");
XSSFCell cell62 = row6.createCell(2);
cell62.setCellStyle(styleCenter);
cell62.setCellValue("0.5"+"-"+"2.9");
CellRangeAddress region624 = new CellRangeAddress(rowNum+1, rowNum+1, 2, 4);//本日
sheet.addMergedRegion(region624);
XSSFCell cell63 = row6.createCell(5);
cell63.setCellStyle(styleCenter);
cell63.setCellValue("0.4"+"-"+"3.33");
CellRangeAddress region66 = new CellRangeAddress(rowNum+1, rowNum+1, 5, 6);//本月累计
sheet.addMergedRegion(region66);
XSSFRow row7 = sheet.createRow(rowNum+2);
XSSFCell cell70 = row7.createCell(0);
cell70.setCellStyle(styleLeft);
cell70.setCellValue("4、服务费收入");
XSSFCell cell71 = row7.createCell(1);
cell71.setCellStyle(styleCenter);
cell71.setCellValue("元");
XSSFCell cell72 = row7.createCell(2);
cell72.setCellStyle(styleCenter);
cell72.setCellValue("5634");
CellRangeAddress region724 = new CellRangeAddress(rowNum+2, rowNum+2, 2, 4);//本日
sheet.addMergedRegion(region724);
XSSFCell cell73 = row7.createCell(5);
cell73.setCellStyle(styleCenter);
cell73.setCellValue("196791.48");
CellRangeAddress region77 = new CellRangeAddress(rowNum+2, rowNum+2, 5, 6);//本月累计
sheet.addMergedRegion(region77);
XSSFRow row8 = sheet.createRow(rowNum+3);
XSSFCell cell80 = row8.createCell(0);
cell80.setCellStyle(styleLeft);
cell80.setCellValue("5、包装收入");
XSSFCell cell81 = row8.createCell(1);
cell81.setCellStyle(styleCenter);
cell81.setCellValue("元");
XSSFCell cell82 = row8.createCell(2);
cell82.setCellStyle(styleCenter);
cell82.setCellValue("3978");
CellRangeAddress region824 = new CellRangeAddress(rowNum+3, rowNum+3, 2, 4);//本日
sheet.addMergedRegion(region824);
XSSFCell cell83 = row8.createCell(5);
cell83.setCellStyle(styleCenter);
cell83.setCellValue("167862.6");
CellRangeAddress region88 = new CellRangeAddress(rowNum+3, rowNum+3, 5, 6);//本月累计
sheet.addMergedRegion(region88);
//---------------------------------------------- 资金收支结余情况↓ ------------------------------------------------------
XSSFRow row9 = sheet.createRow(rowNum+4);
XSSFCell cell90 = row9.createCell(0);
cell90.setCellStyle(styleLeft);
CellRangeAddress region4500 = new CellRangeAddress(rowNum+4, rowNum+5, 0, 0);//本日
sheet.addMergedRegion(region4500);
cell90.setCellValue("二、资金收支结余情况");
XSSFCell cell91 = row9.createCell(1);
cell91.setCellStyle(styleCenter);
CellRangeAddress region4511 = new CellRangeAddress(rowNum+4, rowNum+5, 1, 1);//本日
sheet.addMergedRegion(region4511);
cell91.setCellValue("提款员");
XSSFCell cell92 = row9.createCell(2);
CellRangeAddress region4423 = new CellRangeAddress(rowNum+4, rowNum+4, 2, 3);//本日
sheet.addMergedRegion(region4423);
cell92.setCellStyle(styleCenter);
cell92.setCellValue("发款员");
XSSFRow row10 = sheet.createRow(rowNum+5);
XSSFCell cell102 = row10.createCell(2);
cell102.setCellStyle(styleCenter);
cell102.setCellValue("现金");
XSSFCell cell103 = row10.createCell(3);
cell103.setCellStyle(styleCenter);
cell103.setCellValue("农商行转账");
XSSFCell cell94 = row9.createCell(4);
cell94.setCellStyle(styleCenter);
CellRangeAddress region4544 = new CellRangeAddress(rowNum+4, rowNum+5, 4, 4);//本日
sheet.addMergedRegion(region4544);
cell94.setCellValue("客户欠款");
XSSFCell cell95 = row9.createCell(5);
cell95.setCellStyle(styleCenter);
CellRangeAddress region4555 = new CellRangeAddress(rowNum+4, rowNum+5, 5, 5);//本日
sheet.addMergedRegion(region4555);
cell95.setCellValue("抹零");
XSSFCell cell96 = row9.createCell(6);
cell96.setCellStyle(styleCenter);
CellRangeAddress region4566 = new CellRangeAddress(rowNum+4, rowNum+5, 6, 6);//本日
sheet.addMergedRegion(region4566);
cell96.setCellValue("小计");
XSSFRow row11 = sheet.createRow(rowNum+6);
XSSFCell cell110 = row11.createCell(0);
cell110.setCellStyle(styleLeft);
cell110.setCellValue("1、昨日余额");
for (int i = 0; i < 6; i++) {
XSSFCell cell111 = row11.createCell(i+1);
cell111.setCellStyle(styleCenter);
if (i == 0) {
cell111.setCellValue("440793");//提款员
}
if (i == 1) {
cell111.setCellValue("116023.14");//现金
}
if (i == 2) {
cell111.setCellValue("80578.44");//农商行转账
}
if (i == 3) {
cell111.setCellValue("565667.86");//客户欠款
}
if (i == 4) {
cell111.setCellValue("-95410.4");//抹零
}
if (i == 5) {
cell111.setCellValue("1107652.04");//小计
}
}
//---------------------------------------------- 本日收款↓ ------------------------------------------------------
XSSFRow row12 = sheet.createRow(rowNum+7);
XSSFCell cell120 = row12.createCell(0);
cell120.setCellStyle(styleLeft);
cell120.setCellValue("2、本日收款");
for (int i = 0; i < 6; i++) {
XSSFCell cell121 = row12.createCell(i+1);
cell121.setCellStyle(styleCenter);
if (i == 0) {
cell121.setCellValue("0");//提款员
}
if (i == 1) {
cell121.setCellValue("0");//现金
}
if (i == 2) {
cell121.setCellValue("0");//农商行转账
}
if (i == 3) {
cell121.setCellValue("0");//客户欠款
}
if (i == 4) {
cell121.setCellValue("0");//抹零
}
if (i == 5) {
cell121.setCellValue("0");//小计
}
}
XSSFRow row13 = sheet.createRow(rowNum+8);
XSSFCell cell130 = row13.createCell(0);
cell130.setCellStyle(styleLeft);
cell130.setCellValue("其中:(1)客户来款");
XSSFCell cell131 = row13.createCell(1);
cell131.setCellStyle(styleCenter);
cell131.setCellValue("0");
XSSFRow row14 = sheet.createRow(rowNum+9);
XSSFCell cell140 = row14.createCell(0);
cell140.setCellStyle(styleLeft);
cell140.setCellValue("(2)退包装");
XSSFCell cell141 = row14.createCell(1);
cell141.setCellStyle(styleCenter);
cell141.setCellValue("0");
XSSFRow row15 = sheet.createRow(rowNum+10);
XSSFCell cell150 = row15.createCell(0);
cell150.setCellStyle(styleLeft);
cell150.setCellValue("(3)退余款");
XSSFCell cell151 = row15.createCell(1);
cell151.setCellStyle(styleCenter);
cell151.setCellValue("0");
XSSFRow row16 = sheet.createRow(rowNum+11);
XSSFCell cell160 = row16.createCell(0);
cell160.setCellStyle(styleLeft);
cell160.setCellValue("(4)客户欠款");
XSSFCell cell161 = row16.createCell(1);
cell161.setCellStyle(styleCenter);
cell161.setCellValue("0");
XSSFRow row17 = sheet.createRow(rowNum+12);
XSSFCell cell170 = row17.createCell(0);
cell170.setCellStyle(styleLeft);
cell170.setCellValue("(5)收包装款现金");
XSSFCell cell171 = row17.createCell(1);
cell171.setCellStyle(styleCenter);
cell171.setCellValue("0");
XSSFRow row18 = sheet.createRow(rowNum+13);
XSSFCell cell180 = row18.createCell(0);
cell180.setCellStyle(styleLeft);
cell180.setCellValue("(6)发款员提款");
XSSFCell cell181 = row18.createCell(1);
cell181.setCellStyle(styleCenter);
cell181.setCellValue("0");
for (int i = 0; i < 4; i++) {
//客户来款
XSSFCell cell132 = row13.createCell(i+2);
cell132.setCellStyle(styleCenter);
cell132.setCellValue("0");
//退包装
XSSFCell cell142 = row14.createCell(i+2);
cell142.setCellStyle(styleCenter);
cell142.setCellValue("0");
//退余款
XSSFCell cell152 = row15.createCell(i+2);
cell152.setCellStyle(styleCenter);
cell152.setCellValue("0");
//客户欠款
XSSFCell cell162 = row16.createCell(i+2);
cell162.setCellStyle(styleCenter);
cell162.setCellValue("0");
//收包装款现金
XSSFCell cell172 = row17.createCell(i+2);
cell172.setCellStyle(styleCenter);
cell172.setCellValue("0");
//发款员提款
XSSFCell cell182 = row18.createCell(i+2);
cell182.setCellStyle(styleCenter);
cell182.setCellValue("0");
}
//---------------------------------------------- 本日付款↓ ------------------------------------------------------
XSSFRow row19 = sheet.createRow(rowNum+14);
XSSFCell cell190 = row19.createCell(0);
cell190.setCellStyle(styleLeft);
cell190.setCellValue("3、本日付款");
for (int i = 0; i < 6; i++) {
XSSFCell cell191 = row19.createCell(i+1);
cell191.setCellStyle(styleCenter);
if (i == 0) {
cell191.setCellValue("5");//提款员
}
if (i == 1) {
cell191.setCellValue("5");//现金
}
if (i == 2) {
cell191.setCellValue("5");//农商行转账
}
if (i == 3) {
cell191.setCellValue("5");//客户欠款
}
if (i == 4) {
cell191.setCellValue("5");//抹零
}
if (i == 5) {
cell191.setCellValue("5");//小计
}
}
XSSFRow row20 = sheet.createRow(rowNum+15);
XSSFCell cell200 = row20.createCell(0);
cell200.setCellStyle(styleLeft);
cell200.setCellValue("其中:(1)拨付发款员");
XSSFCell cell201 = row20.createCell(1);
cell201.setCellStyle(styleCenter);
cell201.setCellValue("1");
XSSFRow row21 = sheet.createRow(rowNum+16);
XSSFCell cell210 = row21.createCell(0);
cell210.setCellStyle(styleLeft);
cell210.setCellValue("(2)支付蔬菜款现金");
XSSFCell cell211 = row21.createCell(1);
cell211.setCellStyle(styleCenter);
cell211.setCellValue("1");
XSSFRow row22 = sheet.createRow(rowNum+17);
XSSFCell cell220 = row22.createCell(0);
cell220.setCellStyle(styleLeft);
cell220.setCellValue("(3)支付杂费");
XSSFCell cell221 = row22.createCell(1);
cell221.setCellStyle(styleCenter);
cell221.setCellValue("1");
XSSFRow row23 = sheet.createRow(rowNum+18);
XSSFCell cell230 = row23.createCell(0);
cell230.setCellStyle(styleLeft);
cell230.setCellValue("(4)抹零");
XSSFCell cell231 = row23.createCell(1);
cell231.setCellStyle(styleCenter);
cell231.setCellValue("1");
XSSFRow row24 = sheet.createRow(rowNum+19);
XSSFCell cell240 = row24.createCell(0);
cell240.setCellStyle(styleLeft);
cell240.setCellValue("(5)上交公司款");
XSSFCell cell241 = row24.createCell(1);
cell241.setCellStyle(styleCenter);
cell241.setCellValue("1");
for (int i = 0; i < 4; i++) {
//拨付发款员
XSSFCell cell212 = row20.createCell(i+2);
cell212.setCellStyle(styleCenter);
cell212.setCellValue("1");
//支付蔬菜款现金
XSSFCell cell222 = row21.createCell(i+2);
cell222.setCellStyle(styleCenter);
cell222.setCellValue("1");
//支付杂费
XSSFCell cell232 = row22.createCell(i+2);
cell232.setCellStyle(styleCenter);
cell232.setCellValue("1");
//抹零
XSSFCell cell242 = row23.createCell(i+2);
cell242.setCellStyle(styleCenter);
cell242.setCellValue("1");
//上交公司款
XSSFCell cell252 = row24.createCell(i+2);
cell252.setCellStyle(styleCenter);
cell252.setCellValue("1");
}
//---------------------------------------------- 本日结余↓ ------------------------------------------------------
XSSFRow row25 = sheet.createRow(rowNum+20);
XSSFCell cell250 = row25.createCell(0);
cell250.setCellStyle(styleLeft);
cell250.setCellValue("4、本日结余");
for (int i = 0; i < 6; i++) {
XSSFCell cell251 = row25.createCell(i+1);
cell251.setCellStyle(styleCenter);
if (i == 0) {
cell251.setCellValue("11");
}
if (i == 1) {
cell251.setCellValue("11");
}
if (i == 2) {
cell251.setCellValue("11");
}
if (i == 3) {
cell251.setCellValue("11");
}
if (i == 4) {
cell251.setCellValue("11");
}
if (i == 5) {
cell251.setCellValue("11");
}
}
XSSFRow row26 = sheet.createRow(rowNum+21);
XSSFCell cell260 = row26.createCell(0);
cell260.setCellStyle(styleLeft);
cell260.setCellValue("其中:(1)现金");
XSSFCell cell261 = row26.createCell(1);
cell261.setCellStyle(styleCenter);
cell261.setCellValue("1");
XSSFRow row27 = sheet.createRow(rowNum+22);
XSSFCell cell270 = row27.createCell(0);
cell270.setCellStyle(styleLeft);
cell270.setCellValue("(2)银行卡(个人)");
XSSFCell cell271 = row27.createCell(1);
cell271.setCellStyle(styleCenter);
cell271.setCellValue("1");
XSSFRow row28 = sheet.createRow(rowNum+23);
XSSFCell cell280 = row28.createCell(0);
cell280.setCellStyle(styleLeft);
cell280.setCellValue("(3)微信(个人)");
XSSFCell cell281 = row28.createCell(1);
cell281.setCellStyle(styleCenter);
cell281.setCellValue("1");
XSSFRow row29 = sheet.createRow(rowNum + 24);
XSSFCell cell290 = row29.createCell(0);
cell290.setCellStyle(styleLeft);
cell290.setCellValue("(4)微信收款码");
XSSFCell cell291 = row29.createCell(1);
cell291.setCellStyle(styleCenter);
cell291.setCellValue("1");
XSSFRow row30 = sheet.createRow(rowNum + 25);
XSSFCell cell300 = row30.createCell(0);
cell300.setCellStyle(styleLeft);
cell300.setCellValue("(5)支付宝");
XSSFCell cell301 = row30.createCell(1);
cell301.setCellStyle(styleCenter);
cell301.setCellValue("1");
XSSFRow row31 = sheet.createRow(rowNum + 26);
XSSFCell cell310 = row31.createCell(0);
cell310.setCellStyle(styleLeft);
cell310.setCellValue("(6)信用社公户");
XSSFCell cell311 = row31.createCell(1);
cell311.setCellStyle(styleCenter);
cell311.setCellValue("1");
XSSFRow row32 = sheet.createRow(rowNum + 27);
XSSFCell cell320 = row32.createCell(0);
cell320.setCellStyle(styleLeft);
cell320.setCellValue("(7)客户欠款");
XSSFCell cell321 = row32.createCell(1);
cell321.setCellStyle(styleCenter);
cell321.setCellValue("1");
XSSFRow row33 = sheet.createRow(rowNum + 28);
XSSFCell cell330 = row33.createCell(0);
cell330.setCellStyle(styleLeft);
cell330.setCellValue("(8)客户欠款跟系统差额");
XSSFCell cell331 = row33.createCell(1);
cell331.setCellStyle(styleCenter);
cell331.setCellValue("1");
XSSFRow row34 = sheet.createRow(rowNum + 29);
XSSFCell cell340 = row34.createCell(0);
cell340.setCellStyle(styleLeft);
cell340.setCellValue("(9)余款");
XSSFCell cell341 = row34.createCell(1);
cell341.setCellStyle(styleCenter);
cell341.setCellValue("1");
XSSFRow row35 = sheet.createRow(rowNum + 30);
XSSFCell cell350 = row35.createCell(0);
cell350.setCellStyle(styleLeft);
cell350.setCellValue("(10)其他");
XSSFCell cell351 = row35.createCell(1);
cell351.setCellStyle(styleCenter);
cell351.setCellValue("1");
XSSFRow row36 = sheet.createRow(rowNum + 31);
XSSFCell cell360 = row36.createCell(0);
cell360.setCellStyle(styleLeft);
cell360.setCellValue("(11)抹零");
XSSFCell cell361 = row36.createCell(1);
cell361.setCellStyle(styleCenter);
cell361.setCellValue("1");
for (int i = 0; i < 4; i++) {
// 现金
XSSFCell cell262 = row26.createCell(i+2);
cell262.setCellStyle(styleCenter);
cell262.setCellValue("1");
// 银行卡(个人)
XSSFCell cell272 = row27.createCell(i+2);
cell272.setCellStyle(styleCenter);
cell272.setCellValue("1");
// 微信(个人)
XSSFCell cell282 = row28.createCell(i+2);
cell282.setCellStyle(styleCenter);
cell282.setCellValue("1");
// 微信收款码
XSSFCell cell292 = row29.createCell(i+2);
cell292.setCellStyle(styleCenter);
cell292.setCellValue("1");
// 支付宝
XSSFCell cell302 = row30.createCell(i+2);
cell302.setCellStyle(styleCenter);
cell302.setCellValue("1");
// 信用社公户
XSSFCell cell312 = row31.createCell(i+2);
cell312.setCellStyle(styleCenter);
cell312.setCellValue("1");
// 客户欠款
XSSFCell cell322 = row32.createCell(i+2);
cell322.setCellStyle(styleCenter);
cell322.setCellValue("1");
// 客户欠款跟系统差额
XSSFCell cell332 = row33.createCell(i+2);
cell332.setCellStyle(styleCenter);
cell332.setCellValue("1");
// 余款
XSSFCell cell342 = row34.createCell(i+2);
cell342.setCellStyle(styleCenter);
cell342.setCellValue("1");
// 其他
XSSFCell cell352 = row35.createCell(i+2);
cell352.setCellStyle(styleCenter);
cell352.setCellValue("1");
// 抹零
XSSFCell cell362 = row35.createCell(i+2);
cell362.setCellStyle(styleCenter);
cell362.setCellValue("1");
}
XSSFRow row37 = sheet.createRow(rowNum + 32);
XSSFCell cell370 = row37.createCell(0);
cell370.setCellStyle(styleLeft);
cell370.setCellValue("单位负责人:"+"李经理");
XSSFCell cell376 = row37.createCell(6);
cell376.setCellStyle(styleRight);
cell376.setCellValue("报账员:"+"张三");
//写入文件
String filePath = Global.getDownloadPath() + sheetName;
File file = new File(filePath);
try {
//将文件保存到指定位置
workbook.write(new FileOutputStream(file));
System.out.println("写入文件成功");
} catch (IOException e) {
e.printStackTrace();
}
return file.getAbsolutePath();
}
导出效果图