createSheet Methode welche eine Tabelle erstellt mit User Informationen

get_all_user
Daniel Zdravkovic 2024-06-10 14:17:14 +02:00
parent 5120dd94be
commit 41676607ad
1 changed files with 18 additions and 3 deletions

View File

@ -12,6 +12,8 @@ import java.util.HashSet;
import java.util.TreeSet; import java.util.TreeSet;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.json.JSONObject; import org.json.JSONObject;
public class System { public class System {
@ -19,9 +21,11 @@ public class System {
private User current_user = new User(); private User current_user = new User();
private String api_key; private String api_key;
private ArrayList<String> distances = new ArrayList<>(); private ArrayList<String> distances = new ArrayList<>();
private XSSFWorkbook workbook = new XSSFWorkbook();
public System(String api_key) { public System(String api_key) {
this.api_key = api_key; this.api_key = api_key;
createSheet();
} }
public void set_current_user_zip(String zip){ public void set_current_user_zip(String zip){
@ -53,9 +57,20 @@ public class System {
string = Base64.encodeBase64String(binary_data); string = Base64.encodeBase64String(binary_data);
} }
public void createSheet(){
try
{
XSSFSheet sheet1 = workbook.createSheet("user_information");
FileOutputStream fileOut = new FileOutputStream("workbook.xlsx");
workbook.write(fileOut);
fileOut.close();
}
catch(Exception ex) {}
}
public HashSet<User> get_all_user() throws FileNotFoundException, IOException{ public HashSet<User> get_all_user() throws FileNotFoundException, IOException{
HashSet<User> all_users = new HashSet<>(); HashSet<User> all_users = new HashSet<>();
File file = new File("user_information.csv"); File file = new File("workbook.xlsx");
String[] fileString = new String[8]; String[] fileString = new String[8];
if(file.exists() && file.isFile()){ if(file.exists() && file.isFile()){