2023年10月28日17:54:57
parent
7c5818b543
commit
f094344178
23
pom.xml
23
pom.xml
|
|
@ -23,7 +23,7 @@
|
||||||
<dynamic.verion>3.2.1</dynamic.verion>
|
<dynamic.verion>3.2.1</dynamic.verion>
|
||||||
<oshi.version>3.9.1</oshi.version>
|
<oshi.version>3.9.1</oshi.version>
|
||||||
<velocity.version>1.7</velocity.version>
|
<velocity.version>1.7</velocity.version>
|
||||||
<poi.version>3.17</poi.version>
|
<poi.version>5.2.3</poi.version>
|
||||||
<tk.mybatis.version>2.1.5</tk.mybatis.version>
|
<tk.mybatis.version>2.1.5</tk.mybatis.version>
|
||||||
<pagehelper.version>1.3.0</pagehelper.version>
|
<pagehelper.version>1.3.0</pagehelper.version>
|
||||||
<hutool.version>5.8.15</hutool.version>
|
<hutool.version>5.8.15</hutool.version>
|
||||||
|
|
@ -460,6 +460,27 @@
|
||||||
<artifactId>timi-inject</artifactId>
|
<artifactId>timi-inject</artifactId>
|
||||||
<version>1.4.0</version>
|
<version>1.4.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi-ooxml</artifactId>
|
||||||
|
<version>${poi.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/xerces/xercesImpl -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>xerces</groupId>
|
||||||
|
<artifactId>xercesImpl</artifactId>
|
||||||
|
<version>2.12.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-core</artifactId>
|
||||||
|
<version>2.21.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,97 @@
|
||||||
|
package com.zhangmeng.tools.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.Console;
|
||||||
|
import cn.hutool.poi.excel.ExcelReader;
|
||||||
|
import cn.hutool.poi.excel.ExcelUtil;
|
||||||
|
import cn.hutool.poi.excel.sax.handler.RowHandler;
|
||||||
|
import com.zhangmeng.tools.utils.AlertUtils;
|
||||||
|
import com.zhangmeng.tools.utils.ImagePath;
|
||||||
|
import javafx.application.Platform;
|
||||||
|
import javafx.beans.property.SimpleObjectProperty;
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.control.TableView;
|
||||||
|
import javafx.scene.control.TextField;
|
||||||
|
import javafx.scene.image.Image;
|
||||||
|
import javafx.scene.image.ImageView;
|
||||||
|
import javafx.stage.FileChooser;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class ExcelFileReadController {
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public Button file_choose;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public TableView result_view;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public TextField file_path;
|
||||||
|
|
||||||
|
private final SimpleObjectProperty<File> choose_file = new SimpleObjectProperty<>(null);
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public Button open_excel;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public void initialize() {
|
||||||
|
|
||||||
|
file_choose.setText(null);
|
||||||
|
ImageView iv = new ImageView(new Image(ImagePath.path(ImagePath.ImagePathType.IMAGE_FILE)));
|
||||||
|
iv.setPreserveRatio(true);
|
||||||
|
iv.setFitWidth(18);
|
||||||
|
file_choose.setGraphic(iv);
|
||||||
|
|
||||||
|
//选择文件
|
||||||
|
file_choose.setOnAction(event -> choose_file());
|
||||||
|
|
||||||
|
//打开文件
|
||||||
|
open_excel.setOnAction(event -> {
|
||||||
|
|
||||||
|
if (choose_file.getValue() == null) {
|
||||||
|
AlertUtils.alert_warning("请选择将要识别的pdf再试!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Stage alert = AlertUtils.alert_loading(file_choose.getScene().getWindow());
|
||||||
|
new Thread(() -> {
|
||||||
|
|
||||||
|
//打开文件
|
||||||
|
readBySax();
|
||||||
|
|
||||||
|
Platform.runLater(() -> {
|
||||||
|
log.info("打开文件.....");
|
||||||
|
alert.close();
|
||||||
|
});
|
||||||
|
}).start();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void choose_file() {
|
||||||
|
Stage stage = new Stage();
|
||||||
|
FileChooser dc = new FileChooser();
|
||||||
|
dc.setTitle("文件选择");
|
||||||
|
dc.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("类型", "*.xlsx"));
|
||||||
|
File file = dc.showOpenDialog(stage);
|
||||||
|
if (file != null) {
|
||||||
|
String path = file.getAbsolutePath();
|
||||||
|
file_path.setText(path);
|
||||||
|
log.info("file_path:{}", path);
|
||||||
|
choose_file.set(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void readBySax(){
|
||||||
|
ExcelReader reader = ExcelUtil.getReader(choose_file.getValue());
|
||||||
|
List<Map<String,Object>> readAll = reader.readAll();
|
||||||
|
System.out.println(readAll);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -681,4 +681,8 @@ public class HomeController implements Serializable {
|
||||||
public void timeFx_fx_menu_item(ActionEvent actionEvent) {
|
public void timeFx_fx_menu_item(ActionEvent actionEvent) {
|
||||||
js_edit_list(3);
|
js_edit_list(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void excel_read_menu_item(ActionEvent actionEvent) {
|
||||||
|
load_small_tools(21);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -88,6 +88,7 @@ public class SmallToolsController {
|
||||||
private AnchorPane log_console;
|
private AnchorPane log_console;
|
||||||
private AnchorPane editPlusCode;
|
private AnchorPane editPlusCode;
|
||||||
private AnchorPane minioUpload;
|
private AnchorPane minioUpload;
|
||||||
|
private AnchorPane excel_read;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private ListView<ResourcesUtils.SmallTools> listView;
|
private ListView<ResourcesUtils.SmallTools> listView;
|
||||||
|
|
@ -447,10 +448,33 @@ public class SmallToolsController {
|
||||||
}
|
}
|
||||||
minioUpload(flag);
|
minioUpload(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (newValue.getIndex() == 21){
|
||||||
|
if (excel_read != null) {
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
excel_read(flag);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void excel_read(boolean flag) {
|
||||||
|
//默认选择第一个
|
||||||
|
listView.getSelectionModel().select(21);
|
||||||
|
if (!flag) {
|
||||||
|
try {
|
||||||
|
root = FXMLLoader.load(ResourcesUtils.getResource("excel-read"));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
excel_read = root;
|
||||||
|
} else {
|
||||||
|
root = excel_read;
|
||||||
|
}
|
||||||
|
common_method();
|
||||||
|
}
|
||||||
|
|
||||||
private void minioUpload(boolean flag) {
|
private void minioUpload(boolean flag) {
|
||||||
|
|
||||||
//默认选择第一个
|
//默认选择第一个
|
||||||
|
|
@ -557,6 +581,7 @@ public class SmallToolsController {
|
||||||
case LogConsole -> new Image("image/layui.png");
|
case LogConsole -> new Image("image/layui.png");
|
||||||
case EditPlusCode -> new Image("image/layui.png");
|
case EditPlusCode -> new Image("image/layui.png");
|
||||||
case MinioUpload -> new Image("image/layui.png");
|
case MinioUpload -> new Image("image/layui.png");
|
||||||
|
case ExcelRead -> new Image("image/layui.png");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ public class AlertUtils {
|
||||||
public static Stage alert_loading(Window window) {
|
public static Stage alert_loading(Window window) {
|
||||||
AnchorPane root = null;
|
AnchorPane root = null;
|
||||||
try {
|
try {
|
||||||
root = FXMLLoader.load(ResourcesUtils.getResource("loading"));
|
root = FXMLLoader.load(ResourcesUtils.getResource("load-start"));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -136,6 +136,7 @@ public class ResourcesUtils {
|
||||||
LogConsole("日志输出", 18),
|
LogConsole("日志输出", 18),
|
||||||
EditPlusCode("edit-plus注册码", 19),
|
EditPlusCode("edit-plus注册码", 19),
|
||||||
MinioUpload("minio-upload文件上传", 20),
|
MinioUpload("minio-upload文件上传", 20),
|
||||||
|
ExcelRead("excel-read(表格读取)", 21),
|
||||||
;
|
;
|
||||||
|
|
||||||
SmallTools(String title, int index) {
|
SmallTools(String title, int index) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.control.Button?>
|
||||||
|
<?import javafx.scene.control.Label?>
|
||||||
|
<?import javafx.scene.control.TableView?>
|
||||||
|
<?import javafx.scene.control.TextField?>
|
||||||
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
|
|
||||||
|
<AnchorPane prefHeight="649.0" prefWidth="1200.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.zhangmeng.tools.controller.ExcelFileReadController">
|
||||||
|
<children>
|
||||||
|
<Button fx:id="file_choose" layoutX="510.0" layoutY="40.0" mnemonicParsing="false" text="文件选择" />
|
||||||
|
<Label layoutX="53.0" layoutY="44.0" text="文件:" />
|
||||||
|
<TextField fx:id="file_path" layoutX="99.0" layoutY="40.0" prefHeight="25.0" prefWidth="391.0" />
|
||||||
|
<TableView fx:id="result_view" layoutX="15.0" layoutY="83.0" prefHeight="558.0" prefWidth="1173.0" AnchorPane.bottomAnchor="8.0" AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="12.0" AnchorPane.topAnchor="83.0" />
|
||||||
|
<Button fx:id="open_excel" layoutX="600.0" layoutY="40.0" mnemonicParsing="false" text="打开" />
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
|
@ -54,6 +54,7 @@
|
||||||
<MenuItem mnemonicParsing="false" text="日志输出" onAction="#log_console_menu_item"/>
|
<MenuItem mnemonicParsing="false" text="日志输出" onAction="#log_console_menu_item"/>
|
||||||
<MenuItem mnemonicParsing="false" text="EditPlus注册码生成" onAction="#edit_plus_code_menu_item"/>
|
<MenuItem mnemonicParsing="false" text="EditPlus注册码生成" onAction="#edit_plus_code_menu_item"/>
|
||||||
<MenuItem mnemonicParsing="false" text="minio文件上传" onAction="#minio_upload_menu_item"/>
|
<MenuItem mnemonicParsing="false" text="minio文件上传" onAction="#minio_upload_menu_item"/>
|
||||||
|
<MenuItem mnemonicParsing="false" text="excel文件读取" onAction="#excel_read_menu_item"/>
|
||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue