java-poi-excel-加密
publc class ExcelTest{ public void test1(){ //指定输出内容 File file = new File("E:/20220402/test1.xlsx"); FileOutputStream out = new FileOutputStream(file); // excel内容 SXSSFWorkbook workbook = new SXSSFWorkbook(); SXSSFSheet sheet = workbook.createSheet("test"); SXSSFRow row = sheet.createRow(0); SXSSFCell cell = row.createCell(0); cell.setCellValue("test1"); // 加密内容 EncryptionInfo info = new EncryptionInfo(EncryptionMode.standard); Encryptor enc = info.getEncryptor(); enc.confirmPassword("123456"); // 输出 POIFSFileSystem fs = new POIFSFileSystem(); OutputStream os = enc.getDataStream(fs); workbook.write(os); os.flush(); os.close(); fs.writeFilesystem(out); } }