| | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.write.style.HorizontalCellStyleStrategy; |
| | | import com.yuanchu.mom.service.PerformanceShiftService; |
| | | import com.yuanchu.mom.utils.StyleMonthUtils; |
| | | import com.yuanchu.mom.utils.StyleYearUtils; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | |
| | | |
| | | @Test |
| | | void contextLoads() throws Exception { |
| | | Map<Object, Object> data = performanceShiftService.exportToMonthExcel("2024-05-01 00:00:00", null, null); |
| | | Map<Object, Object> data = performanceShiftService.exportToYearExcel("2024-05-01 00:00:00", null, null); |
| | | // 设置单元格样式 |
| | | HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(StyleMonthUtils.getHeadStyle(), StyleMonthUtils.getContentStyle()); |
| | | HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(StyleYearUtils.getHeadStyle(), StyleYearUtils.getContentStyle()); |
| | | EasyExcel.write(fileName) |
| | | .head((List<List<String>>) data.get("header")) |
| | | .registerWriteHandler(horizontalCellStyleStrategy) |