GanStack
GanStack

Reputation: 1

Read and extract file name from excel cell value

I am having a excel sheet which will have file information like file name , size , last modified date in separate columns . I need to extract file name alone form first column and got to that path and copy that file to other directory using java. Please help me in this

Upvotes: 0

Views: 966

Answers (2)

Arkham
Arkham

Reputation: 11

You can try to use this jar library:

https://afajardomorera.github.io/ExcelReader/

You can define a Java Object with the fields you need, configure a property file and invoke the reader method from the jar.

In the github code, you find a jar_generated folder with the latest version of the jar to use it.

Upvotes: 1

k.honsali
k.honsali

Reputation: 726

I can think of two solutions:

  • export the excel file to .csv so that you can parse it in Java
  • use a more advanced API such as Apache POI, like this:
InputStream fis= new FileInputStream("workbook.xlsx");
Workbook wb = WorkbookFactory.create(fis);
Sheet sheet = wb.getSheetAt(0);
Row row = sheet.getRow(2);
Cell cell = row.getCell(3);

To copy the file, you can use Apache commons' fileUtils.copy

Upvotes: 1

Related Questions