本文主要是介绍JavaFX学习之道:FileChooser 、POI导出Excel文件,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
以下是JavaFX中导出Excel的核心代码:
private HSSFWorkbook workbook;
/* Build Operation Button Area */
Button exportBn = ButtonBuilder.create().text("导出Excel").prefWidth(80).prefHeight(30).build();
exportBn.setDefaultButton(true);
exportBn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
updateQueryResultAllRecords();
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("LaundryService");
fileChooser.setInitialFileName("laundryrecords.xls");
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("XLS Files", "*.xls"));
File file = fileChooser.showSaveDialog(mRecordDetailStage);
if(file != null){
exportExcel(file.getAbsolutePath());
}
}
});
private void exportExcel(String fileName) {
// Declare a work sheet
workbook = new H
这篇关于JavaFX学习之道:FileChooser 、POI导出Excel文件的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!