freepublicview
freepublicview

Reputation: 736

How to get Excel file name when reading the file as inputstream

Trying to read excel(*.xlsx) as binary input stream. Currently using OPCPackage(Apache POI) to open the input stream and then reading the sheet using XSSFReader.

But could not find how can we fetch file name itself when reading as input stream. Any help/suggestion is appreciated

Upvotes: 0

Views: 4080

Answers (1)

Priyamal
Priyamal

Reputation: 2989

Since you are getting input from input stream you can't get the file name.But if you are using file object then you can get the name.

Example:

File file = new File("/path/to/your/file.xlsx");
String fileName = file.getName().split(".")[0]; // "." is the file ext.

Upvotes: 4

Related Questions