How to Write Data into Excel Sheet using Java?
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.
Please Login to comment...