|
@@ -1,11 +1,16 @@
|
|
|
package com.lemon.lifecenter.controller;
|
|
|
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
import java.io.File;
|
|
|
import java.io.FileNotFoundException;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.io.OutputStream;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.net.URLEncoder;
|
|
|
+import java.security.GeneralSecurityException;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
@@ -15,6 +20,13 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
|
|
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
|
+import org.apache.poi.openxml4j.opc.OPCPackage;
|
|
|
+import org.apache.poi.openxml4j.opc.PackageAccess;
|
|
|
+import org.apache.poi.poifs.crypt.EncryptionInfo;
|
|
|
+import org.apache.poi.poifs.crypt.EncryptionMode;
|
|
|
+import org.apache.poi.poifs.crypt.Encryptor;
|
|
|
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
|
import org.apache.poi.ss.usermodel.CellStyle;
|
|
|
import org.apache.poi.ss.usermodel.Font;
|
|
@@ -556,6 +568,15 @@ public class PatientController extends LifeCenterController {
|
|
|
|
|
|
|
|
|
private void getPatientListExcel(HttpServletRequest request, HttpServletResponse response, List<PatientDTO> data ) {
|
|
|
+ String password = LifeCenterSessionController.getSession(request, "sesPhoneNumber");
|
|
|
+ password = password.toLowerCase();
|
|
|
+ if (!password.equals("null")) {
|
|
|
+ password = password.replace("-", "");
|
|
|
+ password = password.substring(3).trim();
|
|
|
+ } else {
|
|
|
+ password = "";
|
|
|
+ }
|
|
|
+
|
|
|
Workbook workbook = new XSSFWorkbook();
|
|
|
Sheet sheet1 = workbook.createSheet("firstSheet");
|
|
|
DecimalFormat df = new DecimalFormat("#,###");
|
|
@@ -754,9 +775,34 @@ public class PatientController extends LifeCenterController {
|
|
|
String tempPath = "../excel-temp/testExcel.xlsx";
|
|
|
String downName = LifeCenterFunction.getNow() + " 환자리스트.xlsx";
|
|
|
File xlsFile = new File(tempPath);
|
|
|
- FileOutputStream fileOut = new FileOutputStream(xlsFile);
|
|
|
+// FileOutputStream fileOut = new FileOutputStream(tempPath);
|
|
|
+// workbook.write(fileOut);
|
|
|
+// fileOut.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);
|
|
|
|
|
|
xlsFile.delete();
|
|
@@ -764,6 +810,12 @@ public class PatientController extends LifeCenterController {
|
|
|
e.printStackTrace();
|
|
|
} 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();
|
|
|
}
|
|
|
}
|
|
|
|