MAJ
This commit is contained in:
parent
0807bdf925
commit
21f3217813
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-19">
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
|
@ -1,8 +1,9 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=19
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=19
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
@ -10,5 +11,5 @@ org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=19
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
|
Binary file not shown.
BIN
fichier.xlsx
BIN
fichier.xlsx
Binary file not shown.
@ -20,7 +20,7 @@ public class CreateCalcWorkbookExample {
|
||||
|
||||
|
||||
public CreateCalcWorkbookExample(Object[][] data){
|
||||
String filePath = Paths.get("").toAbsolutePath().toString()+ "/fichier.xlsx";
|
||||
String filePath = Paths.get("").toAbsolutePath().toString()+ "/base.xlsx";
|
||||
|
||||
|
||||
|
||||
@ -61,10 +61,14 @@ public class CreateCalcWorkbookExample {
|
||||
int rowNum = 1;
|
||||
for (Object[] rowData : data1) {
|
||||
Row row = sheet.createRow(rowNum++);
|
||||
|
||||
int colNum = 0;
|
||||
for (Object cellData : rowData) {
|
||||
Cell cell = row.createCell(colNum++);
|
||||
if (cellData instanceof String) {
|
||||
if(cell.getColumnIndex()==0) {
|
||||
// Dans la colonne A doit se trouver le numéro de l'étudiant de type Integer
|
||||
cell.setCellValue(Integer.valueOf((String) cellData));
|
||||
}else if (cellData instanceof String) {
|
||||
cell.setCellValue((String) cellData);
|
||||
} else if (cellData instanceof Integer) {
|
||||
cell.setCellValue((Integer) cellData);
|
||||
|
93
src/baseUFRHG/ReadExcelExample.java
Normal file
93
src/baseUFRHG/ReadExcelExample.java
Normal file
@ -0,0 +1,93 @@
|
||||
package baseUFRHG;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
public class ReadExcelExample {
|
||||
|
||||
public static void lecture() {
|
||||
|
||||
noeud nBase = recupeBases.recupeLaBase();
|
||||
|
||||
try (FileInputStream fileInputStream = new FileInputStream("base.xlsx");
|
||||
Workbook workbook = new XSSFWorkbook(fileInputStream)) {
|
||||
|
||||
int numSheets = workbook.getNumberOfSheets();
|
||||
|
||||
// Object[][] data = new Object[numSheets][28];
|
||||
|
||||
// int indexSheet = 0;
|
||||
for (int sheetIndex = 0; sheetIndex < numSheets; sheetIndex++) {
|
||||
Sheet sheet = workbook.getSheetAt(sheetIndex);
|
||||
|
||||
if( nBase.getChild(sheet.getSheetName())!=null ) {
|
||||
|
||||
System.out.println("Feuille : " + sheet.getSheetName());
|
||||
noeud nBF = nBase.getChild(sheet.getSheetName());
|
||||
|
||||
|
||||
|
||||
for (Row row : sheet) {
|
||||
int indexCol = 0;
|
||||
noeud nStudent = null;
|
||||
|
||||
for (Cell cell : row) {
|
||||
|
||||
indexCol = cell.getColumnIndex();
|
||||
|
||||
if(indexCol==0) {
|
||||
if (cell.getCellType() == CellType.NUMERIC) {
|
||||
String idStudent = String.valueOf( (int) cell.getNumericCellValue());
|
||||
nStudent = nBF.getChild("n"+idStudent);
|
||||
} else if(cell.getCellType() == CellType.STRING) {
|
||||
String idStudent = cell.getStringCellValue();
|
||||
nStudent = nBF.getChild("n"+idStudent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(nStudent!=null) {
|
||||
CellType cellType = cell.getCellType();
|
||||
if (cellType == CellType.STRING) {
|
||||
String cellValue = cell.getStringCellValue();
|
||||
nStudent.setAttribut(sheet.getRow(0).getCell(indexCol).getStringCellValue(), cellValue);
|
||||
System.out.print(cellValue + " ");
|
||||
} else if (cellType == CellType.NUMERIC) {
|
||||
String cellValue = String.valueOf( (int) cell.getNumericCellValue());
|
||||
nStudent.setAttribut(sheet.getRow(0).getCell(indexCol).getStringCellValue(), cellValue);
|
||||
System.out.print(cellValue + " ");
|
||||
} else if (cellType == CellType.BOOLEAN) {
|
||||
boolean cellValue = cell.getBooleanCellValue();
|
||||
nStudent.setAttribut(sheet.getRow(0).getCell(indexCol).getStringCellValue(),String.valueOf(cellValue));
|
||||
System.out.print(cellValue + " ");
|
||||
} else {
|
||||
// Autres types de cellules (formules, vides, etc.)
|
||||
nStudent.setAttribut(sheet.getRow(0).getCell(indexCol).getStringCellValue(),"");
|
||||
System.out.print("[Type de cellule non pris en charge] ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
System.out.println(); // Nouvelle ligne après chaque ligne du tableau
|
||||
}
|
||||
|
||||
};
|
||||
System.out.println(); // Nouvelle ligne entre les feuilles
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
sauvegardeXMLBase.save(nBase);
|
||||
}
|
||||
}
|
@ -32,7 +32,7 @@ public class base {
|
||||
|
||||
userInput = "Years_" + supprimeCaracatresSpeciaux.TousLesCaracatresSpeciaux(userInput);
|
||||
|
||||
if(!userInput.isBlank()) {
|
||||
if(!userInput.isEmpty()) {
|
||||
nBase.addChild(new noeud(userInput));
|
||||
nBase.setAttribut("defaut_Year", userInput);
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class demarre extends JFrame {
|
||||
frmEvalwriter = new JFrame();
|
||||
frmEvalwriter.setResizable(false);
|
||||
frmEvalwriter.setTitle("Gestion des inscriptions et des groupes - langues - informatique - stage - rentrée");
|
||||
frmEvalwriter.setBounds(100, 100, 607, 438);
|
||||
frmEvalwriter.setBounds(100, 100, 602, 488);
|
||||
int screenWidth = (int) java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getWidth();
|
||||
int screenHeight = (int) java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getHeight();
|
||||
frmEvalwriter.setLocation(( (screenWidth) - frmEvalwriter.getWidth()) / 2, (screenHeight - frmEvalwriter.getHeight()) / 2);
|
||||
@ -58,7 +58,7 @@ public class demarre extends JFrame {
|
||||
// frmEvalwriter.setIconImage(img.getImage());
|
||||
|
||||
btnCreate = new JButton("Exporter base dans classeur MS Excel");
|
||||
btnCreate.setIcon(new ImageIcon(demarre.class.getResource("/resources/renommeEvaluaton.png")));
|
||||
btnCreate.setIcon(new ImageIcon(demarre.class.getResource("/resources/exportInscriptionToBase.png")));
|
||||
btnCreate.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
noeud nBase = recupeBases.recupeLaBase();
|
||||
@ -70,7 +70,7 @@ public class demarre extends JFrame {
|
||||
btnCreate.setFont(new Font("Arial", Font.BOLD, 16));
|
||||
// btnCreate.addActionListener(this);
|
||||
|
||||
btnCreate.setBounds(10, 180, 571, 60);
|
||||
btnCreate.setBounds(10, 211, 566, 60);
|
||||
frmEvalwriter.getContentPane().add(btnCreate);
|
||||
|
||||
actCharge = new JButton("Importer des inscriptions depuis CSV (UTF-8, point-virgule)");
|
||||
@ -80,33 +80,35 @@ public class demarre extends JFrame {
|
||||
}
|
||||
});
|
||||
actCharge.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
actCharge.setIcon(new ImageIcon(demarre.class.getResource("/resources/chargehistoriqueevaluation.png")));
|
||||
actCharge.setIcon(new ImageIcon(demarre.class.getResource("/resources/importInscriptionToBase.png")));
|
||||
actCharge.setBackground(SystemColor.inactiveCaption);
|
||||
// actCharge.addActionListener(this);
|
||||
actCharge.setFont(new Font("Arial", Font.BOLD, 16));
|
||||
actCharge.setBounds(10, 109, 571, 60);
|
||||
actCharge.setBounds(10, 109, 566, 60);
|
||||
frmEvalwriter.getContentPane().add(actCharge);
|
||||
|
||||
JLabel lblNewLabel = new JLabel();
|
||||
lblNewLabel.setIcon(new ImageIcon(demarre.class.getResource("/resources/accueil.png")));
|
||||
// lblNewLabel.setIcon(new ImageIcon(demarre.class.getResource("/resources/accueilanalysecalc.png")));
|
||||
lblNewLabel.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
lblNewLabel.setFont(new Font("Pacifico", Font.PLAIN, 26));
|
||||
lblNewLabel.setBounds(10, 25, 571, 74);
|
||||
lblNewLabel.setBounds(10, 14, 571, 60);
|
||||
frmEvalwriter.getContentPane().add(lblNewLabel);
|
||||
|
||||
JButton btnNewButton = new JButton("Modifier la base depuis classeur MS Excel");
|
||||
JButton btnNewButton = new JButton("Mise à jour de la base depuis classeur MS Excel");
|
||||
btnNewButton.setIcon(new ImageIcon(demarre.class.getResource("/resources/majInscriptionToBase.png")));
|
||||
btnNewButton.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
btnNewButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
ReadExcelExample.lecture();
|
||||
}
|
||||
});
|
||||
btnNewButton.setFont(new Font("Arial", Font.BOLD, 16));
|
||||
// btnNewButton.setIcon(new ImageIcon(demarre.class.getResource("/resources/apropos.png")));
|
||||
btnNewButton.setBounds(10, 258, 571, 60);
|
||||
btnNewButton.setBounds(10, 313, 566, 60);
|
||||
frmEvalwriter.getContentPane().add(btnNewButton);
|
||||
|
||||
JButton btnTutoriels = new JButton("Modifier la base depuis le gestionnaire");
|
||||
JButton btnTutoriels = new JButton("Mise à jour de la base depuis le gestionnaire");
|
||||
btnTutoriels.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
@ -122,11 +124,22 @@ public class demarre extends JFrame {
|
||||
// btnTutoriels.setIcon(new ImageIcon(demarre.class.getResource("/resources/tutoriel.png")));
|
||||
btnTutoriels.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
btnTutoriels.setFont(new Font("Arial", Font.BOLD, 16));
|
||||
btnTutoriels.setBounds(10, 328, 571, 60);
|
||||
btnTutoriels.setBounds(10, 375, 566, 60);
|
||||
frmEvalwriter.getContentPane().add(btnTutoriels);
|
||||
|
||||
JLabel lblNewLabel_1 = new JLabel("Inscriptions des étudiants depuis un fichier");
|
||||
lblNewLabel_1.setFont(new Font("Arial", Font.BOLD, 14));
|
||||
lblNewLabel_1.setBounds(10, 77, 385, 30);
|
||||
frmEvalwriter.getContentPane().add(lblNewLabel_1);
|
||||
|
||||
JLabel lblNewLabel_1_1 = new JLabel("Exporter la base");
|
||||
lblNewLabel_1_1.setFont(new Font("Arial", Font.BOLD, 14));
|
||||
lblNewLabel_1_1.setBounds(10, 180, 347, 30);
|
||||
frmEvalwriter.getContentPane().add(lblNewLabel_1_1);
|
||||
|
||||
JLabel lblNewLabel_1_1_1 = new JLabel("Mise à jour de la base");
|
||||
lblNewLabel_1_1_1.setFont(new Font("Arial", Font.BOLD, 14));
|
||||
lblNewLabel_1_1_1.setBounds(10, 283, 347, 30);
|
||||
frmEvalwriter.getContentPane().add(lblNewLabel_1_1_1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ public class exportBaseToExcel {
|
||||
|
||||
public static void export(noeud nBase) {
|
||||
|
||||
// Données pour les colonnes A et B
|
||||
// Données
|
||||
Object[][] data = new Object[nBase.getChild(nBase.getAttributes("defaut_Year")).getNumberChildren()][28];
|
||||
|
||||
int indexFormation = 0 ;
|
||||
|
@ -1,14 +1,9 @@
|
||||
package baseUFRHG;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
|
@ -1,12 +1,5 @@
|
||||
package baseUFRHG;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
public class majBase {
|
||||
@ -21,7 +14,7 @@ public class majBase {
|
||||
for(int i = 0 ; i < nCSV.getChildren().size();i++) {
|
||||
|
||||
if(nCSV.getChildren().get(i).getAttributes("IAE_-_Etape_lib.")!=null) {
|
||||
if(!nCSV.getChildren().get(i).getAttributes("IAE_-_Etape_lib.").isBlank()) {
|
||||
if(!nCSV.getChildren().get(i).getAttributes("IAE_-_Etape_lib.").isEmpty()) {
|
||||
if(!isExisteFormationIntoBase(nBase, nCSV.getChildren().get(i).getAttributes("IAE_-_Etape_lib."))) {
|
||||
nBase.getChild(defaut_Year).addChild(new noeud( supprimeCaracatresSpeciaux.TousLesCaracatresSpeciaux(nCSV.getChildren().get(i).getAttributes("IAE_-_Etape_lib."))));
|
||||
}
|
||||
@ -32,15 +25,8 @@ public class majBase {
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Sauvegarde de la base
|
||||
String directoryName = Paths.get("").toAbsolutePath().toString()+ "/base.xml";
|
||||
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
|
||||
new FileOutputStream(directoryName), StandardCharsets.UTF_8))) {
|
||||
writer.write(nBase.toWrite());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
sauvegardeXMLBase.save(nBase);
|
||||
|
||||
//Affiche le nombre d'étudiant ajouté à la base.
|
||||
JOptionPane.showMessageDialog(null, "Nombre d'étudiant ajouté à la base : " + String.valueOf(compteurAddStudent));
|
||||
@ -65,7 +51,7 @@ public class majBase {
|
||||
private static noeud majStudentIntoBase(noeud nBase, noeud nStudent) {
|
||||
if (nStudent.getAttributes("IAE_-_Etape_lib.")!=null && nStudent.getAttributes("Individu_-_Code_Etudiant")!=null){
|
||||
|
||||
if(isValidEightDigits(nStudent.getAttributes("Individu_-_Code_Etudiant")) && !nStudent.getAttributes("IAE_-_Etape_lib.").isBlank() ) {
|
||||
if(isValidEightDigits(nStudent.getAttributes("Individu_-_Code_Etudiant")) && !nStudent.getAttributes("IAE_-_Etape_lib.").isEmpty() ) {
|
||||
if(isExisteFormationIntoBase(nBase, nStudent.getAttributes("IAE_-_Etape_lib."))) {
|
||||
|
||||
noeud nBF = nBase.getChild(defaut_Year).getChild(supprimeCaracatresSpeciaux.TousLesCaracatresSpeciaux(nStudent.getAttributes("IAE_-_Etape_lib.")));
|
||||
|
@ -331,7 +331,7 @@ public class noeud {
|
||||
*/
|
||||
public boolean hasContent() {
|
||||
if(this.content!=null) {
|
||||
if(!this.content.isBlank()) return true;
|
||||
if(!this.content.isEmpty()) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
24
src/baseUFRHG/sauvegardeXMLBase.java
Normal file
24
src/baseUFRHG/sauvegardeXMLBase.java
Normal file
@ -0,0 +1,24 @@
|
||||
package baseUFRHG;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class sauvegardeXMLBase {
|
||||
|
||||
public static void save(noeud nBase) {
|
||||
|
||||
// Sauvegarde de la base
|
||||
String directoryName = Paths.get("").toAbsolutePath().toString()+ "/base.xml";
|
||||
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
|
||||
new FileOutputStream(directoryName), StandardCharsets.UTF_8))) {
|
||||
writer.write(nBase.toWrite());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
BIN
src/resources/accueil.png
Normal file
BIN
src/resources/accueil.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.6 KiB |
BIN
src/resources/exportInscriptionToBase.png
Normal file
BIN
src/resources/exportInscriptionToBase.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
BIN
src/resources/importInscriptionToBase.png
Normal file
BIN
src/resources/importInscriptionToBase.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
BIN
src/resources/majInscriptionToBase.png
Normal file
BIN
src/resources/majInscriptionToBase.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
Loading…
x
Reference in New Issue
Block a user