Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit b35f577

Browse files
committed
16 fix bugs caused by incorrect import and no-name input file
1 parent 1b77b75 commit b35f577

File tree

8 files changed

+43
-7
lines changed

8 files changed

+43
-7
lines changed

.idea/artifacts/DeskSorting_jar.xml

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/libraries/commons_collections4_4_42.xml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

DeskSorting.iml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@
2323
<orderEntry type="library" name="commons-collections4-4.4" level="project" />
2424
<orderEntry type="library" name="jfoenix-8.0.10" level="project" />
2525
<orderEntry type="library" name="poi-ooxml-lite-5.0.0" level="project" />
26+
<orderEntry type="library" name="commons-collections4-4.4" level="project" />
2627
</component>
2728
</module>
342 Bytes
Binary file not shown.

out/production/DeskSorting/cn/rocket/deksrt/resource/MainWindow.fxml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@
4747
<Font size="15.0" />
4848
</font></Label>
4949
</GridPane>
50-
<JFXButton fx:id="importB" buttonType="RAISED" layoutX="40.0" layoutY="25.0" onAction="#impM" prefHeight="40.0" prefWidth="100.0" ripplerFill="BLACK" stylesheets="@style.css" text="导入..." AnchorPane.leftAnchor="40.0">
50+
<JFXButton fx:id="importB" buttonType="RAISED" layoutX="40.0" layoutY="25.0" onAction="#impM" prefHeight="40.0" prefWidth="100.0" ripplerFill="BLACK" stylesheets="@style.css" text="导入...">
5151
<font>
5252
<Font size="15.0" />
5353
</font>
5454
</JFXButton>
55-
<JFXButton fx:id="exportB" buttonType="RAISED" layoutX="173.0" layoutY="25.0" onAction="#expM" prefHeight="40.0" prefWidth="100.0" ripplerFill="BLACK" stylesheets="@style.css" text="导出..." AnchorPane.leftAnchor="173.0" AnchorPane.topAnchor="25.0">
55+
<JFXButton fx:id="exportB" buttonType="RAISED" layoutX="178.0" layoutY="25.0" onAction="#expM" prefHeight="40.0" prefWidth="100.0" ripplerFill="BLACK" stylesheets="@style.css" text="导出..." AnchorPane.leftAnchor="173.0" AnchorPane.topAnchor="25.0">
5656
<font>
5757
<Font size="15.0" />
5858
</font>
5959
</JFXButton>
60-
<JFXButton fx:id="randSort" buttonType="RAISED" layoutX="436.0" layoutY="25.0" onAction="#randM" prefHeight="40.0" prefWidth="100.0" ripplerFill="BLACK" stylesheets="@style.css" text="随机排">
60+
<JFXButton fx:id="randSort" buttonType="RAISED" layoutX="442.0" layoutY="25.0" onAction="#randM" prefHeight="40.0" prefWidth="100.0" ripplerFill="BLACK" stylesheets="@style.css" text="随机排">
6161
<font>
6262
<Font size="15.0" />
6363
</font>
@@ -72,7 +72,7 @@
7272
<Font size="15.0" />
7373
</font>
7474
</JFXTextField>
75-
<JFXCheckBox fx:id="quickSwapCB" layoutX="310.0" layoutY="25.0" onAction="#quickSwapM" prefHeight="40.0" prefWidth="100.0" stylesheets="@style.css" text="快速交换">
75+
<JFXCheckBox fx:id="quickSwapCB" layoutX="316.0" layoutY="25.0" onAction="#quickSwapM" prefHeight="40.0" stylesheets="@style.css" text="快速交换">
7676
<font>
7777
<Font size="15.0" />
7878
</font>

src/cn/rocket/deksrt/main/Entry.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
import javafx.scene.Parent;
88
import javafx.scene.Scene;
99
import javafx.stage.Stage;
10+
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
11+
import org.apache.poi.openxml4j.opc.OPCPackage;
1012
import org.apache.poi.ss.usermodel.*;
13+
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
1114

1215
import java.io.*;
1316
import java.nio.charset.StandardCharsets;
@@ -38,10 +41,12 @@ public void start(Stage primaryStage) throws Exception {
3841
}
3942

4043
/**
44+
* <b>EXIT CODE 99, 100 HERE</b>
45+
*
4146
* @return errors in xlsx file
4247
* @throws IOException if input a incorrect file
4348
*/
44-
private String scanStuInfo() throws IOException {
49+
private String scanStuInfo() throws IOException, InvalidFormatException {
4550
StringBuilder errors = new StringBuilder();
4651
InputStream in = this.getClass().getResourceAsStream(GlobalVariables.stuInfoTemplateP);
4752
File infoXlsx = new File(GlobalVariables.jarParentPath + "StuInfo.xlsx");
@@ -50,7 +55,8 @@ private String scanStuInfo() throws IOException {
5055
Files.copy(in, infoXlsx.toPath());
5156
System.exit(99);
5257
} else {
53-
Workbook wb = WorkbookFactory.create(infoXlsx);
58+
OPCPackage opcPackage = OPCPackage.open(infoXlsx);
59+
XSSFWorkbook wb = new XSSFWorkbook(opcPackage);
5460
GlobalVariables.stuInfo = new StudentList<>(52);
5561
StudentList<Student> stuIn = GlobalVariables.stuInfo;
5662

@@ -95,6 +101,10 @@ private String scanStuInfo() throws IOException {
95101
if (!stuIn.contains(queue))
96102
stuIn.add(new Student(name, pinyin.toLowerCase(), boarding));
97103
}
104+
if (stuIn.size() == 0) {
105+
System.err.println("No names in input file!");
106+
System.exit(100);
107+
}
98108
System.out.println("name\tpy\tboarding");
99109
for (Student student : stuIn)
100110
System.out.println(student);

src/cn/rocket/deksrt/main/MainWindow.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void initialize() throws IllegalAccessException {
9292
iod = null;
9393
try {
9494
iod = FXMLLoader.load(Objects.requireNonNull(
95-
MainWindow.class.getResource("/cn/rocket/deksrt/resource/IOportDialog.fxml")
95+
MainWindow.class.getResource("/cn/rocket/deksrt/resource/IEportDialog.fxml")
9696
));
9797
} catch (IOException e) {
9898
e.printStackTrace();
File renamed without changes.

0 commit comments

Comments
 (0)