Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. Workbook workbook = new Workbook(file);
  2. Sheet sheet = workbook.getSheetAt(0); // get first sheet
  3. Iterator<Row> iterator = sheet.iterator();
  4.  
  5. while (iterator.hasNext()) {
  6. Iterator<Cell> cellIterator = iterator.next().iterator();
  7. while (cellIterator.hasNext()) {
  8. Cell c = cellIterator.next();
  9. // add to data structure
  10. }
  11. }
  12.  
  13. String[][] data; // loaded from XLSX
  14. CSVPrinter printer = new CSVPrinter(new File("output.csv"), CSVFormat.DEFAULT);
  15. printer.printRecord("Column 1", "Column 2", "Column 3"); // print header
  16.  
  17. for (String[] strings : data) {
  18. printer.printRecord(strings[0], strings[1], strings[2]);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement