Java POI 에서 xssf로 비밀번호 저장하기

SimpleDateFormat sdfSaveFile = new SimpleDateFormat(“yyyyMMdd”); String outFile = “Report_” + sdfSaveFile.format(new Date())+ “.xlsx”; System.out.println(“Saving ” + outFile); FileOutputStream out = new FileOutputStream(outFile); wb.write(out); out.close(); POIFSFileSystem fs = new POIFSFileSystem(); EncryptionInfo info = new EncryptionInfo(fs, EncryptionMode.agile); Encryptor enc = info.getEncryptor(); enc.confirmPassword(“your_password”); OPCPackage opc = OPCPackage.open(new File(outFile),PackageAccess.READ_WRITE); OutputStream os = enc.getDataStream(fs); opc.save(os); opc.close(); FileOutputStream fos = new FileOutputStream(outFile); fs.writeFilesystem(fos); fos.close(); 참고사이트: http://www.quicklyjava.com/create-password-protected-excel-using-apache-poi/]]>

Related Posts