private void writeTimeslotHoursVertically(List<Timeslot> dayTimeslotList) { for (Timeslot timeslot : dayTimeslotList) { nextRow(); nextCell().setCellValue(TIME_FORMATTER.format(timeslot.getStartDateTime()) + "-" + TIME_FORMATTER.format(timeslot.getEndDateTime())); currentRow.setHeightInPoints(3 * currentSheet.getDefaultRowHeightInPoints()); } }
private void writePersonMeetingList(Person person, boolean required) { nextRow(); currentRow.setHeightInPoints(2 * currentSheet.getDefaultRowHeightInPoints()); nextHeaderCell(person.getFullName()); if (required) { nextHeaderCell("Required"); } else { currentSheet.addMergedRegion(new CellRangeAddress(currentRowNumber - 1, currentRowNumber, currentColumnNumber, currentColumnNumber)); nextHeaderCell("Preferred"); } List<Meeting> personMeetingList; if (required) { personMeetingList = solution.getAttendanceList().stream() .filter(attendance -> attendance.getPerson().equals(person) && attendance instanceof RequiredAttendance) .map(Attendance::getMeeting) .collect(toList()); } else { personMeetingList = solution.getAttendanceList().stream() .filter(attendance -> attendance.getPerson().equals(person) && attendance instanceof PreferredAttendance) .map(Attendance::getMeeting) .collect(toList()); } List<MeetingAssignment> personMeetingAssignmentList = solution.getMeetingAssignmentList().stream() .filter(meetingAssignment -> personMeetingList.contains(meetingAssignment.getMeeting())) .collect(toList()); writeMeetingAssignmentList(personMeetingAssignmentList); }
void nextMeetingAssignmentListCell(List<MeetingAssignment> meetingAssignmentList, Function<MeetingAssignment, String> stringFunction, List<String> filteredConstraintNames) { if (meetingAssignmentList == null) { meetingAssignmentList = Collections.emptyList(); } HardMediumSoftScore score = meetingAssignmentList.stream() .map(indictmentMap::get).filter(Objects::nonNull) .flatMap(indictment -> indictment.getConstraintMatchSet().stream()) // Filter out filtered constraints .filter(constraintMatch -> filteredConstraintNames == null || filteredConstraintNames.contains(constraintMatch.getConstraintName())) .map(constraintMatch -> (HardMediumSoftScore) constraintMatch.getScore()) // Filter out positive constraints .filter(indictmentScore -> !(indictmentScore.getHardScore() >= 0 && indictmentScore.getSoftScore() >= 0)) .reduce(Score::add).orElse(HardMediumSoftScore.ZERO); XSSFCell cell = getXSSFCellOfScore(score); if (!meetingAssignmentList.isEmpty()) { ClientAnchor anchor = creationHelper.createClientAnchor(); anchor.setCol1(cell.getColumnIndex()); anchor.setCol2(cell.getColumnIndex() + 4); anchor.setRow1(currentRow.getRowNum()); anchor.setRow2(currentRow.getRowNum() + 4); Comment comment = currentDrawing.createCellComment(anchor); String commentString = getMeetingAssignmentListString(meetingAssignmentList); comment.setString(creationHelper.createRichTextString(commentString)); cell.setCellComment(comment); } cell.setCellValue(meetingAssignmentList.stream().map(stringFunction).collect(joining("\n"))); currentRow.setHeightInPoints(Math.max(currentRow.getHeightInPoints(), meetingAssignmentList.size() * currentSheet.getDefaultRowHeightInPoints())); }
currentRow.setHeightInPoints(Math.max(currentRow.getHeightInPoints(), talkList.size() * currentSheet.getDefaultRowHeightInPoints()));
private void writeRoomsView() { nextSheet("Rooms view", 1, 2, true); nextRow(); nextHeaderCell(""); writeTimeGrainDaysHeaders(); nextRow(); nextHeaderCell("Room"); writeTimeGrainHoursHeaders(); for (Room room : solution.getRoomList()) { nextRow(); currentRow.setHeightInPoints(2 * currentSheet.getDefaultRowHeightInPoints()); nextCell().setCellValue(room.getName()); List<MeetingAssignment> roomMeetingAssignmentList = solution.getMeetingAssignmentList().stream() .filter(meetingAssignment -> meetingAssignment.getRoom() == room).collect(toList()); writeMeetingAssignmentList(roomMeetingAssignmentList); } autoSizeColumnsWithHeader(); }
for (Room room : solution.getRoomList()) { nextRow(); currentRow.setHeightInPoints(3 * currentSheet.getDefaultRowHeightInPoints()); nextCell().setCellValue(room.getName()); List<Talk> roomTalkList = solution.getTalkList().stream()
private void writeTimeslotHoursVertically(List<Timeslot> dayTimeslotList) { for (Timeslot timeslot : dayTimeslotList) { nextRow(); nextCell().setCellValue(TIME_FORMATTER.format(timeslot.getStartDateTime()) + "-" + TIME_FORMATTER.format(timeslot.getEndDateTime())); currentRow.setHeightInPoints(3 * currentSheet.getDefaultRowHeightInPoints()); } }
private void writePersonMeetingList(Person person, boolean required) { nextRow(); currentRow.setHeightInPoints(2 * currentSheet.getDefaultRowHeightInPoints()); nextHeaderCell(person.getFullName()); if (required) { nextHeaderCell("Required"); } else { currentSheet.addMergedRegion(new CellRangeAddress(currentRowNumber - 1, currentRowNumber, currentColumnNumber, currentColumnNumber)); nextHeaderCell("Preferred"); } List<Meeting> personMeetingList; if (required) { personMeetingList = solution.getAttendanceList().stream() .filter(attendance -> attendance.getPerson().equals(person) && attendance instanceof RequiredAttendance) .map(Attendance::getMeeting) .collect(toList()); } else { personMeetingList = solution.getAttendanceList().stream() .filter(attendance -> attendance.getPerson().equals(person) && attendance instanceof PreferredAttendance) .map(Attendance::getMeeting) .collect(toList()); } List<MeetingAssignment> personMeetingAssignmentList = solution.getMeetingAssignmentList().stream() .filter(meetingAssignment -> personMeetingList.contains(meetingAssignment.getMeeting())) .collect(toList()); writeMeetingAssignmentList(personMeetingAssignmentList); }
void nextMeetingAssignmentListCell(List<MeetingAssignment> meetingAssignmentList, Function<MeetingAssignment, String> stringFunction, List<String> filteredConstraintNames) { if (meetingAssignmentList == null) { meetingAssignmentList = Collections.emptyList(); } HardMediumSoftScore score = meetingAssignmentList.stream() .map(indictmentMap::get).filter(Objects::nonNull) .flatMap(indictment -> indictment.getConstraintMatchSet().stream()) // Filter out filtered constraints .filter(constraintMatch -> filteredConstraintNames == null || filteredConstraintNames.contains(constraintMatch.getConstraintName())) .map(constraintMatch -> (HardMediumSoftScore) constraintMatch.getScore()) // Filter out positive constraints .filter(indictmentScore -> !(indictmentScore.getHardScore() >= 0 && indictmentScore.getSoftScore() >= 0)) .reduce(Score::add).orElse(HardMediumSoftScore.ZERO); XSSFCell cell = getXSSFCellOfScore(score); if (!meetingAssignmentList.isEmpty()) { ClientAnchor anchor = creationHelper.createClientAnchor(); anchor.setCol1(cell.getColumnIndex()); anchor.setCol2(cell.getColumnIndex() + 4); anchor.setRow1(currentRow.getRowNum()); anchor.setRow2(currentRow.getRowNum() + 4); Comment comment = currentDrawing.createCellComment(anchor); String commentString = getMeetingAssignmentListString(meetingAssignmentList); comment.setString(creationHelper.createRichTextString(commentString)); cell.setCellComment(comment); } cell.setCellValue(meetingAssignmentList.stream().map(stringFunction).collect(joining("\n"))); currentRow.setHeightInPoints(Math.max(currentRow.getHeightInPoints(), meetingAssignmentList.size() * currentSheet.getDefaultRowHeightInPoints())); }
currentRow.setHeightInPoints(Math.max(currentRow.getHeightInPoints(), talkList.size() * currentSheet.getDefaultRowHeightInPoints()));
headerRow.setHeightInPoints(80); XSSFCell titleCell = headerRow.createCell(0); titleCell.setCellValue(months[month] + " " + year); for (int j = 0; j < 6; j++) { XSSFRow row = sheet.createRow(rownum++); row.setHeightInPoints(100); for (int i = 0; i < days.length; i++) { XSSFCell dayCell_1 = row.createCell(i * 2);
private void writeRoomsView() { nextSheet("Rooms view", 1, 2, true); nextRow(); nextHeaderCell(""); writeTimeGrainDaysHeaders(); nextRow(); nextHeaderCell("Room"); writeTimeGrainHoursHeaders(); for (Room room : solution.getRoomList()) { nextRow(); currentRow.setHeightInPoints(2 * currentSheet.getDefaultRowHeightInPoints()); nextCell().setCellValue(room.getName()); List<MeetingAssignment> roomMeetingAssignmentList = solution.getMeetingAssignmentList().stream() .filter(meetingAssignment -> meetingAssignment.getRoom() == room).collect(toList()); writeMeetingAssignmentList(roomMeetingAssignmentList); } autoSizeColumnsWithHeader(); }
for (Room room : solution.getRoomList()) { nextRow(); currentRow.setHeightInPoints(3 * currentSheet.getDefaultRowHeightInPoints()); nextCell().setCellValue(room.getName()); List<Talk> roomTalkList = solution.getTalkList().stream()
public static void main(String[] args) throws IOException { try (XSSFWorkbook wb = new XSSFWorkbook()) { XSSFSheet sheet = wb.createSheet(); XSSFRow row = sheet.createRow(2); row.setHeightInPoints(30); for (int i = 0; i < 8; i++) { //column width is set in units of 1/256th of a character width sheet.setColumnWidth(i, 256 * 15); } createCell(wb, row, 0, HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM); createCell(wb, row, 1, HorizontalAlignment.CENTER_SELECTION, VerticalAlignment.BOTTOM); createCell(wb, row, 2, HorizontalAlignment.FILL, VerticalAlignment.CENTER); createCell(wb, row, 3, HorizontalAlignment.GENERAL, VerticalAlignment.CENTER); createCell(wb, row, 4, HorizontalAlignment.JUSTIFY, VerticalAlignment.JUSTIFY); createCell(wb, row, 5, HorizontalAlignment.LEFT, VerticalAlignment.TOP); createCell(wb, row, 6, HorizontalAlignment.RIGHT, VerticalAlignment.TOP); //center text over B4, C4, D4 row = sheet.createRow(3); centerAcrossSelection(wb, row, 1, 3, VerticalAlignment.CENTER); // Write the output to a file try (OutputStream fileOut = new FileOutputStream("xssf-align.xlsx")) { wb.write(fileOut); } } }