use of org.controlsfx.control.spreadsheet.SpreadsheetCell in project Gargoyle by callakrsos.
the class SchoolMgrerSpreadSheetView method miSaveAsOnAction.
/**
* 파일 저장 처리.
* @작성자 : KYJ
* @작성일 : 2016. 12. 27.
* @param event
*/
public void miSaveAsOnAction(ActionEvent event) {
File saveFile = DialogUtil.showFileSaveCheckDialog(getScene().getWindow(), chooser -> {
chooser.getExtensionFilters().add(new ExtensionFilter(GargoyleExtensionFilters.XLSX_NAME, GargoyleExtensionFilters.XLSX));
});
if (saveFile != null) {
ThreadUtil.createNewThreadAndRun(() -> {
try (Workbook workBookXlsx = ExcelUtil.createNewWorkBookXlsx()) {
Sheet createSheet = workBookXlsx.createSheet("Sheet1");
ObservableList<ObservableList<SpreadsheetCell>> rows = gagoyleSpreadSheetView.getRows();
IntStream.iterate(0, r -> r + 1).limit(rows.size()).forEach(rIndex -> {
ObservableList<SpreadsheetCell> cellList = rows.get(rIndex);
IntStream.iterate(0, a -> a + 1).limit(cellList.size()).forEach(cidx -> {
SpreadsheetCell spreadsheetCell = cellList.get(cidx);
String text = spreadsheetCell.getText();
try {
ExcelUtil.createCell(createSheet, text, rIndex, cidx);
} catch (Exception e1) {
e1.printStackTrace();
}
});
});
workBookXlsx.write(new FileOutputStream(saveFile));
} catch (IOException e) {
e.printStackTrace();
}
});
}
}
Aggregations