This library is a wrapper over poi.apache . With this library, you can write your java.class to an Excel file. You do not have to do a lot of actions to write data.
Use this setup for Maven:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.Fizick1</groupId>
<artifactId>Nopl</artifactId>
<version>v0.2.0</version>
</dependency>
and for Gradle:
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.Fizick1:Nopl:v0.2.0'
}
User.class
class Users(
val name: String,
val age: Byte,
val city: String,
val secretKey: String
)
Easy record of the list with the data in the file ".xlsx". The method creates a file and writes data to it.
- If you reuse this method with a list of the same class as before, the old file will be overwritten.
- Whatever happens, use the following method .
val listUsers = listOf(
Users("Stive",45,"Moscow","haqGRCsYkT"),
Users("Ned",93,"London","NuzDNH3E0U"),
Users("Clarice",18,"Ashdod","+UQl]DL(47h7jvn"),
Users("Natalia",76,"Port Harcourt","l{v)7OFF@D27m^)"),
Users("Charlie",65,"Abakan","s8HBkmhA4L"),
Users("Lorie",31,"Bandung","U]|&Sxd2;F}Mw")
)
Nopl().writeTable(listUsers)
Writes data to your workbook sent in the parameters. The recording is done by adding a new sheet to your workbook. If you use this method, you will have to create and save the file yourself.
val workbook = SXSSFWorkbook()
Nopl().writeTable(listUsers, workbook)
val file = File("Example.xlsx")
FileOutputStream(file).use { workbook.write(it) }
Adds data to your sheet, passed in the parameters. In the case of overlaying one data to the other, the old ones will be retouched. So that when you add new data, the old ones were saved, you can add the settings of the starting positions for the table. Note that the position report starts at 0.
//...//
val workSheet = workbook.createSheet("ExampleSheet")
val coordinates = StartCell(5,5)
Nopl().writeTable(listUsers, workSheet,coordinates)
//...//
You can also add a note @ColumnName
in order to override the name of the column that will be displayed in the file. Also, using the @Output
note, you can exclude this column from output to a file.
class Users(
@ColumnName("User name")
val name: String,
@ColumnName("User age")
val age: Byte,
@ColumnName("Location")
val city: String,
@Output(false)
val secretKey: String
)