use of org.odftoolkit.simple.table.Cell in project LAMSADE-tools by LAntoine.
the class generateMissionOrder method generateSpreadsheetDocument.
/**
* User Instantiation and fill the Spreadsheet
* @throws Exception when something went wrong with the generation
* */
public void generateSpreadsheetDocument() throws Exception {
UserDetails user = GetInfosFromYearbook.getUserDetails(lastname, firstname);
try (InputStream inputStream = generateMissionOrder.class.getResourceAsStream("ordre_de_mission.ods");
SpreadsheetDocument spreadsheetDoc = SpreadsheetDocument.loadDocument(inputStream)) {
//Name
Cell nameCell = spreadsheetDoc.getSheetByName("Feuil1").getCellByPosition("F8");
nameCell.setStringValue(user.getName());
//Firstname
Cell firstNameCell = spreadsheetDoc.getSheetByName("Feuil1").getCellByPosition("Y8");
firstNameCell.setStringValue(user.getFirstName());
//mail
Cell mailCell = spreadsheetDoc.getSheetByName("Feuil1").getCellByPosition("F11");
mailCell.setStringValue(user.getEmail());
//Departure Data - One Way trip
Cell cityCountryDepartureCell = spreadsheetDoc.getSheetByName("Feuil1").getCellByPosition("B31");
cityCountryDepartureCell.setStringValue(user.getCity() + " ," + user.getCountry());
//Arrival Data - Return trip
Cell cityCountryArrivalCell = spreadsheetDoc.getSheetByName("Feuil1").getCellByPosition("T37");
cityCountryArrivalCell.setStringValue(user.getCity() + " ," + user.getCountry());
spreadsheetDoc.save("ordre_de_mission_test.ods");
inputStream.close();
// spreadsheetDoc.close();
}
}
Aggregations