From 8b688597b8ccd76eab576716ac18cb51c0e6861f Mon Sep 17 00:00:00 2001 From: erdanergou Date: Thu, 30 Mar 2023 08:37:26 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=99=E8=A6=81=E4=B8=8B=E8=BD=BD=E7=9A=84?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E8=AE=BE=E7=BD=AE=E7=BC=96=E8=BE=91=E5=AF=86?= =?UTF-8?q?=E7=A0=81=EF=BC=88=E6=89=93=E5=8D=B0=E5=8D=95=E7=9A=84=E7=94=B3?= =?UTF-8?q?=E8=AF=B7=E6=97=B6=E9=97=B4=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ExcelServiceImpl.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/com/dreamchaser/depository_manage/service/impl/ExcelServiceImpl.java b/src/main/java/com/dreamchaser/depository_manage/service/impl/ExcelServiceImpl.java index a5d4134a..a40c1736 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/impl/ExcelServiceImpl.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/impl/ExcelServiceImpl.java @@ -18,6 +18,8 @@ import com.dreamchaser.depository_manage.service.*; import com.dreamchaser.depository_manage.utils.*; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.ClassPathResource; import org.springframework.stereotype.Service; @@ -617,6 +619,14 @@ public class ExcelServiceImpl implements ExcelService { map.put("page", i); map.put("pagesum", pagesum); excelWriter.fill(map, writeSheet); + + // 用于添加权限 + Workbook workbook = excelWriter.writeContext().writeWorkbookHolder().getWorkbook(); + int numberOfSheets = workbook.getNumberOfSheets(); + for (int x = 0; x < numberOfSheets; x++) { + Sheet sheetAt = workbook.getSheetAt(x); + sheetAt.protectSheet(record.getApplicantTime()); + } } fileNameList.add(fileName); }