Handling files is an important part of any programming language. Java provides various in-built methods for creating, reading, updating, and deleting files. These methods are provided by the File class which is present in the java.io package. To perform file operations, Java uses the stream class.
To do operations in excel sheets using JAVA, it comes in handy to use the CSV files because CSV files can easily be used with Microsoft Excel, Google spreadsheets, and almost all other spreadsheets available.
To write data into an excel sheet itself using poi :
1. Create a blank workbook.
XSSFWorkbook workbook = new XSSFWorkbook();
2. Create a sheet and name it.
XSSFSheet spreadsheet = workbook.createSheet(" Student Data ");
3. Create a row
Row row = sheet.createRow(rownum++);
4. Add cells to the sheet.
5. Repeat Steps 3 and 4 to write the complete data.
Prerequisite: Add all jar files downloaded from Apache POI download site in Java Program’s build path.
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.