質問編集履歴
3
createメソッドを使用するように変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -18,38 +18,29 @@
|
|
18
18
|
### 該当のソースコード
|
19
19
|
|
20
20
|
```java
|
21
|
+
public class Main {
|
21
|
-
public static void main(String[] args)
|
22
|
+
public static void main(String[] args) {
|
22
|
-
System.out.
|
23
|
+
System.out.println("start: main");
|
23
24
|
|
24
|
-
excelOpenXlsxPassword("C://GCS/template.xlsx", "abc");
|
25
|
-
|
26
|
-
System.out.print("end: main\r\n");
|
27
|
-
}
|
28
|
-
|
29
|
-
/**
|
30
|
-
* パスワード付きExcelファイルの読み込み&書き込み。
|
31
|
-
* @param filePath Excelファイルのフルパス
|
32
|
-
* @param password パスワード
|
33
|
-
* @throws IOException
|
34
|
-
*/
|
35
|
-
public static void excelOpenXlsxPassword(String filePath, String password) throws EncryptedDocumentException, IOException {
|
36
|
-
FileInputStream
|
25
|
+
FileInputStream in = null;
|
37
|
-
POIFSFileSystem fileSystem = null;
|
38
|
-
InputStream is = null;
|
39
|
-
Workbook
|
26
|
+
Workbook tempbook = null;
|
40
27
|
try {
|
41
|
-
|
28
|
+
in = new FileInputStream("test.xlsx");
|
29
|
+
tempbook = WorkbookFactory.create(in, "abc");
|
30
|
+
} catch (IOException e) {
|
42
|
-
|
31
|
+
System.out.print(e.toString());
|
43
|
-
|
32
|
+
} finally {
|
44
|
-
|
33
|
+
try {
|
45
|
-
|
34
|
+
if (tempbook != null) {
|
35
|
+
tempbook.close();
|
36
|
+
}
|
37
|
+
} catch (IOException e) {
|
46
|
-
System.out.
|
38
|
+
System.out.print("終了処理で入出力例外が発生!");
|
47
|
-
return;
|
48
|
-
}else{
|
49
|
-
System.out.println("解除成功");
|
50
39
|
}
|
40
|
+
}
|
51
|
-
|
41
|
+
System.out.println("読込完了");
|
52
|
-
|
42
|
+
}
|
43
|
+
}
|
53
44
|
```
|
54
45
|
|
55
46
|
### 試したこと
|
2
バージョン追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -58,4 +58,7 @@
|
|
58
58
|
US_export_policy.jar
|
59
59
|
local_policy.jar
|
60
60
|
|
61
|
-
|
61
|
+
### 補足情報
|
62
|
+
java 1.8.0_381
|
63
|
+
apache poi 5.2.3
|
64
|
+
jce_policy 8
|
1
不要なコードを削除
title
CHANGED
File without changes
|
body
CHANGED
@@ -21,21 +21,8 @@
|
|
21
21
|
public static void main(String[] args) throws Exception {
|
22
22
|
System.out.print("start: main\r\n");
|
23
23
|
|
24
|
-
Workbook tempbook = null;
|
25
|
-
try {
|
26
|
-
|
24
|
+
excelOpenXlsxPassword("C://GCS/template.xlsx", "abc");
|
27
|
-
|
25
|
+
|
28
|
-
System.out.print("入出力例外が発生!");
|
29
|
-
} finally {
|
30
|
-
//--- テンプレートをクローズ --//
|
31
|
-
try {
|
32
|
-
if (tempbook != null) {
|
33
|
-
tempbook.close();
|
34
|
-
}
|
35
|
-
} catch (IOException e) {
|
36
|
-
System.out.print("終了処理で入出力例外が発生!");
|
37
|
-
}
|
38
|
-
}
|
39
26
|
System.out.print("end: main\r\n");
|
40
27
|
}
|
41
28
|
|