Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get filename of xlsx file with apache poi XSSF?

How to get filename of xlsx file with apache poi XSSF?

case class XlsxSplitter(path: InputStream){

  lazy val spreadSheet=load(path)

  def load(path: InputStream):SpreadSheet={
    val wb = new XSSFWorkbook(path)
    .........
  }
}

I could extract it from the path, but I would like to make my case class as generic as possible.

like image 400
YoBre Avatar asked Jan 27 '26 11:01

YoBre


1 Answers

If you're able to change the path attribute to a attribute of type File instead of InputStream, you can get the filename from the file itself by file.getName();

Otherwise I think you have no other choice than extracting it by yourself.

like image 129
winklerrr Avatar answered Jan 29 '26 00:01

winklerrr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!