![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/96954173203c4c0a884a31eab2edaff9.png#pic_center)
```java
public void calenderTest(HttpServletResponse res, IntegrationPlan integrationPlan) throws IOException {
BufferedOutputStream outputStream = null;
String downloadFileName = URLEncoder.encode("notes", "UTF-8");
res.setHeader("content-type", "application/octet-stream");
res.setContentType("application/x-execl");
res.setHeader("Content-Disposition",
"attachment;filename=" + new String((downloadFileName).getBytes(), "UTF-8") + ".xlsx");
Workbook workbook = new XSSFWorkbook();
Sheet sheet = workbook.createSheet("Calendar");
CellStyle weekStyle = getCellStyle(workbook, true, 16, "黑体", BorderStyle.MEDIUM);
CellStyle dateStyle = getCellStyle(workbook, true, 16, "宋体", BorderStyle.THIN);
CellStyle infoStyle = getCellStyle(workbook, false, 16, "宋体", BorderStyle.MEDIUM);
Row headerRow = sheet.createRow(0);
for (int i = 0; i < 7; i++) {
headerRow.createCell(i).setCellValue(WeekDateEnum.of(i + 1).getName());
headerRow.getCell(i).setCellStyle(weekStyle);
headerRow.setHeightInPoints(40);
sheet.setColumnWidth(i, 40 * 256);
}
String checkMonth = integrationPlan.getCheckMonth();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM");
Date date = null;
try {
date = dateFormat.parse(checkMonth);
} catch (ParseException e) {
throw new RuntimeException(e);
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
Instant instant = date.toInstant();
ZoneId zone = ZoneId.systemDefault();
LocalDate localDate = instant.atZone(zone).toLocalDate();
int startCell = localDate.getDayOfWeek().getValue() - 1;
Row currentRow = sheet.createRow(1);
Row nextRow = sheet.createRow(2);
int month = calendar.get(Calendar.MONTH) + 1;
int day = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
int dayCount = 1;
while (dayCount <= day) {
currentRow.createCell(startCell).setCellValue(month + "月" + dayCount + "日");
currentRow.getCell(startCell).setCellStyle(dateStyle);
nextRow.createCell(startCell).setCellValue("111");
nextRow.getCell(startCell).setCellStyle(infoStyle);
nextRow.setHeightInPoints(250);
startCell++;
dayCount++;
if (startCell == 7) {
currentRow = sheet.createRow(currentRow.getRowNum() + 2);
nextRow = sheet.createRow(nextRow.getRowNum() + 2);
startCell = 0;
}
}
outputStream = new BufferedOutputStream(res.getOutputStream());
workbook.write(outputStream);
outputStream.flush();
workbook.close();
}