This example demonstrates how Excel library can work with large Excel files.
// second parameter is a special flag that allows to save memory
ExcelDocument doc = new ExcelDocument("input_400k.xlsx", true);
Sheet sheet = doc.getActiveSheet();
Table<Passenger> passengersTable = sheet.findTable(Passenger.class, MatchMethod.EXACT, "Passenger Id");
for (int i = 350000; i <= 360000; i++) {
Passenger p = passengersTable.getRecord(i);
if (p.getPassengerId() % 1000 == 0) {
...
}
}
// second parameter is a special flag that allows to save memory
ExcelDocument doc = new ExcelDocument("input_400k.xlsx", true);
Sheet sheet = doc.getActiveSheet();
Table<Passenger> passengersTable = activeSheet.findTable(Passenger.class, "Passenger Id", "Name");
//Lookup record by specific condition in the table
Integer passengerId = 35500;
Passenger record = passengersTable.findRecord(r -> passengerId.equals(r.getPassengerId()));
//Edit Age of the record
record.setAge(110);
//Update corresponding record on sheet
passengersTable.updateRecord(record);
doc.save();
See the full source of this example for more details or check following instructions to run it.
⚠️ To be able to build and run this example it's necessary to have an access to some instance of EasyRPA Control Server.
Its a fully workable process. To play around with it and run do the following:
-
Download this example using link.
-
Unpack it somewhere on local file system.
-
Specify URL to the available instance of EasyRPA Control Server in the
pom.xml
of this example:<repositories> <repository> <id>easy-rpa-repository</id> <url>[Replace with EasyRPA Control Server URL]/nexus/repository/easyrpa/</url> </repository> </repositories>
-
If necessary, change version of
easy-rpa-engine-parent
in the samepom.xml
to corresponding version of EasyRPA Control Server:<parent> <groupId>eu.ibagroup</groupId> <artifactId>easy-rpa-engine-parent</artifactId> <version>[Replace with version of EasyRPA Control Server]</version> </parent>
-
Build it using
mvn clean install
command. This command should be run within directory of this example. -
Run
main()
method ofWorkingWithLargeFilesModule
class.
All necessary configuration files can be found in src/main/resources
directory.
apm_run.properties
Parameter | Value |
---|---|
source.spreadsheet.file | Path to the source spreadsheet file. It can be path on local file system or within resources of this module. |
output.files.dir | Path to directory on local file system where robot will put all modified within this process example spreadsheet files. |