use of com.kyj.fx.voeditor.visual.functions.ToExcelFileFunction in project Gargoyle by callakrsos.
the class SqlPane method menuExportExcelOnAction.
/**
* Excel Export.
*
* @param e
*/
public void menuExportExcelOnAction(ActionEvent e) {
File saveFile = DialogUtil.showFileSaveDialog(SharedMemory.getPrimaryStage().getOwner(), option -> {
option.setInitialFileName(DateUtil.getCurrentDateString(DateUtil.SYSTEM_DATEFORMAT_YYYYMMDDHHMMSS));
option.getExtensionFilters().add(new ExtensionFilter("Excel files (*.xlsx)", "*.xlsx"));
option.getExtensionFilters().add(new ExtensionFilter("Excel files (*.xls)", "*.xls"));
option.getExtensionFilters().add(new ExtensionFilter("All files", "*.*"));
option.setTitle("Save Excel");
option.setInitialDirectory(new File(SystemUtils.USER_HOME));
});
if (saveFile == null) {
return;
}
if (saveFile.exists()) {
Optional<Pair<String, String>> showYesOrNoDialog = DialogUtil.showYesOrNoDialog("overwrite ?? ", FILE_OVERWIRTE_MESSAGE);
showYesOrNoDialog.ifPresent(consume -> {
String key = consume.getKey();
String value = consume.getValue();
if (!("RESULT".equals(key) && "Y".equals(value))) {
return;
}
});
}
ObservableList<Map<String, Object>> items = this.tbResult.getItems();
ToExcelFileFunction toExcelFileFunction = new ToExcelFileFunction();
List<String> columns = this.tbResult.getColumns().stream().map(col -> col.getText()).collect(Collectors.toList());
toExcelFileFunction.generate0(saveFile, columns, items);
DialogUtil.showMessageDialog("complete...");
}
use of com.kyj.fx.voeditor.visual.functions.ToExcelFileFunction in project Gargoyle by callakrsos.
the class SqlMultiplePane method menuExportExcelOnAction.
/**
* 엑셀 export기능
*
* @param tbResult
*
* @param e
*/
public void menuExportExcelOnAction(TableView<Map<String, Object>> tbResult) {
File saveFile = DialogUtil.showFileSaveDialog(SharedMemory.getPrimaryStage().getOwner(), option -> {
option.setInitialFileName(DateUtil.getCurrentDateString(DateUtil.SYSTEM_DATEFORMAT_YYYYMMDDHHMMSS));
option.getExtensionFilters().add(new ExtensionFilter(GargoyleExtensionFilters.XLSX_NAME, GargoyleExtensionFilters.XLSX));
option.getExtensionFilters().add(new ExtensionFilter(GargoyleExtensionFilters.XLS_NAME, GargoyleExtensionFilters.XLS));
option.getExtensionFilters().add(new ExtensionFilter("All files", "*.*"));
option.setTitle("Save Excel");
option.setInitialDirectory(new File(SystemUtils.USER_HOME));
});
if (saveFile == null) {
return;
}
if (saveFile.exists()) {
Optional<Pair<String, String>> showYesOrNoDialog = DialogUtil.showYesOrNoDialog("overwrite ?? ", FILE_OVERWIRTE_MESSAGE);
showYesOrNoDialog.ifPresent(consume -> {
String key = consume.getKey();
String value = consume.getValue();
if (!("RESULT".equals(key) && "Y".equals(value))) {
return;
}
});
}
ObservableList<Map<String, Object>> items = tbResult.getItems();
ToExcelFileFunction toExcelFileFunction = new ToExcelFileFunction();
List<String> columns = tbResult.getColumns().stream().map(col -> col.getText()).collect(Collectors.toList());
toExcelFileFunction.generate0(saveFile, columns, items);
DialogUtil.showMessageDialog("complete...");
}
use of com.kyj.fx.voeditor.visual.functions.ToExcelFileFunction in project Gargoyle by callakrsos.
the class FxUtil method exportExcelFile.
/**
* tableView의 item을 엑셀파일로 전환
* @작성자 : KYJ
* @작성일 : 2017. 3. 31.
* @param saveFile
* @param tableView
*/
public static void exportExcelFile(File saveFile, TableView<?> tableView) {
List<Map<String, Object>> items = tableView.getItems().stream().map(v -> {
if (v instanceof Map) {
return (Map<String, Object>) v;
}
return (Map<String, Object>) ObjectUtil.toMap(v);
}).collect(Collectors.toList());
// ObservableList<Map<String, Object>> items = this.tbResult.getItems();
ToExcelFileFunction toExcelFileFunction = new ToExcelFileFunction();
List<String> columns = tableView.getColumns().stream().map(col -> col.getText()).collect(Collectors.toList());
toExcelFileFunction.generate0(saveFile, columns, items);
DialogUtil.showMessageDialog("complete...");
}
Aggregations