use of kyj.Fx.dao.wizard.core.model.vo.TableModelDVO in project Gargoyle by callakrsos.
the class VoEditorController method btnExcelImporOnMouseClick.
@FXML
public void btnExcelImporOnMouseClick() {
File selectFile = DialogUtil.showFileDialog(SharedMemory.getPrimaryStage(), new Consumer<FileChooser>() {
@Override
public void accept(FileChooser choser) {
String fileName = txtClassName.getText();
// File dir = SystemUtils.getUserDir();
choser.setInitialFileName(fileName);
// choser.setInitialDirectory(dir);
choser.getExtensionFilters().add(new ExtensionFilter(GargoyleExtensionFilters.XLSX_NAME, GargoyleExtensionFilters.XLSX, GargoyleExtensionFilters.XLS));
}
});
if (selectFile != null && selectFile.exists()) {
try {
String simpleName = selectFile.getName();
String className = simpleName.substring(0, simpleName.indexOf("."));
txtClassName.setText(className);
// TODO 좀 더 깔끔한 방법으로 작성하는걸 고려.. ex) template기반
List<TableModelDVO> list = ExcelUtil.toK(selectFile, new BiFunction<File, Workbook, List<TableModelDVO>>() {
@Override
public List<TableModelDVO> apply(File file, Workbook xlsx) {
List<TableModelDVO> llist = new ArrayList<>();
Sheet sheetAt = xlsx.getSheetAt(0);
// 데이터부 처리
for (int _row = 3; _row <= sheetAt.getLastRowNum(); _row++) {
Row row = sheetAt.getRow(_row);
Cell column = row.getCell(0);
Cell type = row.getCell(1);
Cell size = row.getCell(2);
Cell comment = row.getCell(3);
TableModelDVO modelDVO = new TableModelDVO();
modelDVO.setName(column.getStringCellValue());
modelDVO.setType(type.getStringCellValue());
modelDVO.setSize(size.getStringCellValue());
modelDVO.setDesc(comment.getStringCellValue());
llist.add(modelDVO);
}
return llist;
}
});
tbVoEditor.getItems().clear();
tbVoEditor.getItems().addAll(list);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Aggregations