Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
6fad9523
Commit
6fad9523
authored
13 years ago
by
kaloyane
Browse files
Options
Downloads
Patches
Plain Diff
minor bugfix: close excel files after reading their contents
SVN: 22353
parent
124c55c2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/utils/ExcelFileReader.java
+17
-9
17 additions, 9 deletions
...isd/openbis/dss/generic/shared/utils/ExcelFileReader.java
with
17 additions
and
9 deletions
datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/utils/ExcelFileReader.java
+
17
−
9
View file @
6fad9523
...
...
@@ -24,6 +24,7 @@ import java.util.Arrays;
import
java.util.List
;
import
org.apache.commons.io.FilenameUtils
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.log4j.Logger
;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook
;
import
org.apache.poi.poifs.filesystem.POIFSFileSystem
;
...
...
@@ -104,17 +105,24 @@ public class ExcelFileReader
{
final
String
extension
=
FilenameUtils
.
getExtension
(
file
.
getName
()).
toLowerCase
();
final
FileInputStream
stream
=
new
FileInputStream
(
file
);
if
(
"xls"
.
equals
(
extension
))
try
{
POIFSFileSystem
poifsFileSystem
=
new
POIFSFileSystem
(
stream
);
return
new
HSSFWorkbook
(
poifsFileSystem
);
}
else
if
(
"xlsx"
.
equals
(
extension
))
{
return
new
XSSFWorkbook
(
stream
);
}
else
if
(
"xls"
.
equals
(
extension
))
{
POIFSFileSystem
poifsFileSystem
=
new
POIFSFileSystem
(
stream
);
return
new
HSSFWorkbook
(
poifsFileSystem
);
}
else
if
(
"xlsx"
.
equals
(
extension
))
{
return
new
XSSFWorkbook
(
stream
);
}
else
{
throw
new
IllegalArgumentException
(
"Expected an Excel file with 'xls' or 'xlsx' extension, got "
+
file
.
getName
());
}
}
finally
{
throw
new
IllegalArgumentException
(
"Expected an Excel file with 'xls' or 'xlsx' extension, got "
+
file
.
getName
());
IOUtils
.
closeQuietly
(
stream
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment