Sfoglia il codice sorgente

입퇴소 통계 엑셀다운로드 비밀번호 추가

huiwon.seo 4 anni fa
parent
commit
b56f6328c6

+ 32 - 32
src/main/java/com/lemon/lifecenter/controller/PatientStatistics.java

@@ -339,33 +339,33 @@ public class PatientStatistics extends LifeCenterController {
           String tempPath = "../excel-temp/testExcel.xlsx";
           String downName = LifeCenterFunction.getNow() + " 환자입퇴소통계.xlsx";
           File xlsFile = new File(tempPath);
-          FileOutputStream fileOut = new FileOutputStream(tempPath);
-          workbook.write(fileOut);
-//          fileOut.close();
-          
-//          ByteArrayOutputStream fileOut = new ByteArrayOutputStream();
-//          FileOutputStream fos = new FileOutputStream(tempPath);
+//          FileOutputStream fileOut = new FileOutputStream(tempPath);
 //          workbook.write(fileOut);
-//          
-//          InputStream filein = new ByteArrayInputStream(fileOut.toByteArray());
-//          OPCPackage opc = OPCPackage.open(filein);
-//
-//          POIFSFileSystem fileSystem = new POIFSFileSystem();
-//
-//          EncryptionInfo encryptionInfo = new EncryptionInfo(EncryptionMode.agile);
-//          Encryptor encryptor = encryptionInfo.getEncryptor();
-//          encryptor.confirmPassword(password);
-//
-//          opc.save(encryptor.getDataStream(fileSystem));
-//          opc.flush();
-//          
-//          fileSystem.writeFilesystem(fos);
-//          
 //          fileOut.close();
-//          opc.close();
-//          
-//          filein.close();
-//          fileSystem.close();
+          
+          ByteArrayOutputStream fileOut = new ByteArrayOutputStream();
+          FileOutputStream fos = new FileOutputStream(tempPath);
+          workbook.write(fileOut);
+          
+          InputStream filein = new ByteArrayInputStream(fileOut.toByteArray());
+          OPCPackage opc = OPCPackage.open(filein);
+
+          POIFSFileSystem fileSystem = new POIFSFileSystem();
+
+          EncryptionInfo encryptionInfo = new EncryptionInfo(EncryptionMode.agile);
+          Encryptor encryptor = encryptionInfo.getEncryptor();
+          encryptor.confirmPassword(password);
+
+          opc.save(encryptor.getDataStream(fileSystem));
+          opc.flush();
+          
+          fileSystem.writeFilesystem(fos);
+          
+          fileOut.close();
+          opc.close();
+          
+          filein.close();
+          fileSystem.close();
           
           LifeCenterFileDownload.download(request, response, tempPath, downName);
 
@@ -375,12 +375,12 @@ public class PatientStatistics extends LifeCenterController {
       } catch (IOException e) {
           e.printStackTrace();
       } 
-//        catch (InvalidFormatException e) {
-//        // TODO Auto-generated catch block
-//        e.printStackTrace();
-//        } catch (GeneralSecurityException e) {
-//            // TODO Auto-generated catch block
-//            e.printStackTrace();
-//        }
+        catch (InvalidFormatException e) {
+        // TODO Auto-generated catch block
+        e.printStackTrace();
+        } catch (GeneralSecurityException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
     }
 }