Hackforge Academy

Category: java

read Excel files

Published on 26 May 2026

Explanation

Spring Boot can read Excel files using Apache POI library. Apache POI helps in processing .xls and .xlsx files.

Code:

<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>5.2.5</version>
</dependency>

Explanation

Upload the Excel file using MultipartFile in a REST API.

Code:

@PostMapping("/upload")
public String readExcel(
@RequestParam("file") MultipartFile file) {
    return "Excel Received";
}

Explanation

Read Excel workbook and sheet using Apache POI.

Code:

Workbook workbook = new XSSFWorkbook(
file.getInputStream());
Sheet sheet = workbook.getSheetAt(0);

Explanation

Loop through rows and cells to read Excel data.

Code:

for (Row row : sheet) {
    for (Cell cell : row) {
        System.out.print(cell.toString() 
+ " ");
    }
    System.out.println();
}

Explanation

Complete flow: Client uploads Excel file -> Spring Boot receives MultipartFile -> Apache POI reads workbook -> Data is processed or stored in database.

Code:

Client --> Spring Boot API --> 
MultipartFile --> Apache POI -->
 Excel Data Processing

πŸš€ Learn Spring Boot with real-world projects

πŸ’‘ Build REST APIs step by step

🧠 Improve backend development skills

🎯 Get career-ready practical training

Join Our Free WhatsApp Community

Direct access to niche-specific mentors and peers on WhatsApp.

🐍

Python Community

Discuss Django, FastAPI, AI integration, and automation scripts with 15k+ developers.

Join Python Community
βš›οΈ

React Community

Master Next.js, Framer Motion, and State Management. Share your latest UI components.

Join React Community
β˜•

Java Community

Deep dives into Spring Boot, Microservices architecture, and high-performance backend ops.

Join Java Community