|
3 | 3 | import java.io.ByteArrayInputStream;
|
4 | 4 | import java.io.ByteArrayOutputStream;
|
5 | 5 | import java.io.IOException;
|
| 6 | +import java.io.InputStream; |
6 | 7 | import java.util.ArrayList;
|
7 | 8 | import java.util.List;
|
8 | 9 |
|
@@ -44,21 +45,25 @@ public ExcelSpreadsheet(IGXError errHandler, String fileName, String template) t
|
44 | 45 | fileName += ".xlsx";
|
45 | 46 | }
|
46 | 47 |
|
47 |
| - if (!template.equals("")) { |
48 |
| - GXFile templateFile = new GXFile(template); |
49 |
| - if (templateFile.exists()) { |
50 |
| - _workbook = new XSSFWorkbook(templateFile.getStream()); |
51 |
| - } else { |
52 |
| - throw new ExcelTemplateNotFoundException(); |
53 |
| - } |
54 |
| - } else { |
55 |
| - GXFile file = new GXFile(fileName, Constants.EXTERNAL_PRIVATE_UPLOAD); |
56 |
| - if (file.exists()) { |
57 |
| - _workbook = new XSSFWorkbook(file.getStream()); |
| 48 | + InputStream is = null; |
| 49 | + try { |
| 50 | + if (!template.equals("")) { |
| 51 | + GXFile templateFile = new GXFile(template); |
| 52 | + if (templateFile.exists()) { |
| 53 | + is = templateFile.getStream(); |
| 54 | + _workbook = new XSSFWorkbook(); |
| 55 | + } else { |
| 56 | + throw new ExcelTemplateNotFoundException(); |
| 57 | + } |
58 | 58 | } else {
|
59 |
| - _workbook = new XSSFWorkbook(); |
| 59 | + GXFile file = new GXFile(fileName, Constants.EXTERNAL_PRIVATE_UPLOAD); |
| 60 | + if (file.exists()) { |
| 61 | + _workbook = new XSSFWorkbook(file.getStream()); |
| 62 | + } else { |
| 63 | + _workbook = new XSSFWorkbook(); |
| 64 | + } |
60 | 65 | }
|
61 |
| - } |
| 66 | + } finally { if (is != null) is.close(); } |
62 | 67 |
|
63 | 68 | _documentFileName = fileName;
|
64 | 69 |
|
|
0 commit comments