![]() ![]() Let's create a method that writes a list of persons to a sheet titled “Persons”.įirst, we will create and style a header row that contains “Name” and “Age” cells: Workbook workbook = new XSSFWorkbook() When the cell type enum value is STRING, the content will be read using the getRichStringCellValue() method of the Cell interface: data.get(new Integer(i)).add(cell.getRichStringCellValue().getString()) Ĭells having the NUMERIC content type can contain either a date or a number and are read in the following manner:Īpache POI uses the same interfaces presented in the previous section for writing to an Excel file and has better support for styling than JExcel. Let's expand on the content of each switch case above. Next, let's retrieve the first sheet of the file and iterate through each row: Sheet sheet = workbook.getSheetAt(0) ĭefault: data.get(new Integer(i)).add(" ") Īpache POI has different methods for reading each type of data. Workbook workbook = new XSSFWorkbook(file) First, let's open the file from a given location: FileInputStream file = new FileInputStream(new File(fileLocation)) ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |