https://grokonez.com/java/java-read-write-excel-file-apache-poi-example

Java – How to read/write Excel file with Apache POI

In this tutorial, we’re gonna look at examples that read and write Excel file using Apache POI.

I. Dependency

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

II. Write Data to Excel File

- Simple POJO Customer (id, name, address, age):

package com.javasampleapproach.excelpoi;

public class Customer {
private String id;
private String name;
private String address;
private int age;

public Customer() {
}

public Customer(String id, String name, String address, int age) {
	this.id = id;
	this.name = name;
	this.address = address;
	this.age = age;
}

public String getId() {
	return id;
}

public void setId(String id) {
	this.id = id;
}

public String getName() {
	return name;
}

public void setName(String name) {
	this.name = name;
}

public String getAddress() {
	return address;
}

public void setAddress(String address) {
	this.address = address;
}

public int getAge() {
	return age;
}

public void setAge(int age) {
	this.age = age;
}

@Override
public String toString() {
	return "Customer [id=" + id + ", name=" + name + ", address=" + address + ", age=" + age + "]";
}

}

  • Write to Excel file:

More at:

https://grokonez.com/java/java-read-write-excel-file-apache-poi-example

Java – How to read/write Excel file with Apache POI

#java #excel #apache-poi

Java - How to read/write Excel file with Apache POI » grokonez
1.60 GEEK