protected void nextHeaderCell(double value) { nextCell(headerStyle).setCellValue(value); headerCellCount++; }
/** * Set a string value for the cell. * * @param str value to set the cell to. For formulas we'll set the formula * cached string result, for String cells we'll set its value. For other types we will * change the cell to a string cell and set its value. * If value is null then we will change the cell to a Blank cell. */ @Override public void setCellValue(String str) { setCellValue(str == null ? null : new XSSFRichTextString(str)); }
protected void nextHeaderCellVertically(String value) { nextCellVertically(headerStyle).setCellValue(value); headerCellCount++; }
protected void nextHeaderCell(String value) { nextCell(headerStyle).setCellValue(value); headerCellCount++; }
protected void writeIntConstraintParameterLine(String name, Supplier<Integer> supplier, String constraintDescription) { nextRow(); nextHeaderCell(name); XSSFCell weightCell = nextCell(); if (supplier != null) { weightCell.setCellValue(supplier.get()); } else { weightCell.setCellValue("n/a"); } nextHeaderCell(constraintDescription); }
protected void writeLongConstraintParameterLine(String name, Supplier<Long> supplier, String constraintDescription) { nextRow(); nextHeaderCell(name); XSSFCell weightCell = nextCell(); if (supplier != null) { weightCell.setCellValue(supplier.get()); } else { weightCell.setCellValue("n/a"); } nextHeaderCell(constraintDescription); }
XSSFDataFormat df = workBook.createDataFormat(); cs.setDataFormat(df.getFormat("d-mmm-yy")); // Get / Create our cell XSSFRow row = sheet.createRow(2); XSSFCell cell = row.createCell(3); // Set it to be a date Calendar c = Calendar.getInstance(); c.set(2012,3-1,18); // Don't forget months are 0 based on Calendar cell.setCellValue( c.getTime() ); // Style it as a date cell.setCellStyle(cs);
protected <Score_ extends Score<Score_>> void writeScoreConstraintLine( String constraintName, Score_ constraintScore, String constraintDescription) { nextRow(); nextHeaderCell(constraintName); nextCell(scoreDefinition.getZeroScore().equals(constraintScore) ? disabledScoreStyle : scoreStyle) .setCellValue(constraintScore.toString()); nextHeaderCell(constraintDescription); }
private void writeTimeslotList() { nextSheet("Timeslots", 3, 1, false); nextRow(); nextHeaderCell("Day"); nextHeaderCell("Start"); nextHeaderCell("End"); nextHeaderCell("Talk types"); nextHeaderCell("Tags"); for (Timeslot timeslot : solution.getTimeslotList()) { nextRow(); nextCell().setCellValue(DAY_FORMATTER.format(timeslot.getDate())); nextCell().setCellValue(TIME_FORMATTER.format(timeslot.getStartDateTime())); nextCell().setCellValue(TIME_FORMATTER.format(timeslot.getEndDateTime())); nextCell().setCellValue(String.join(", ", timeslot.getTalkTypeSet().stream().map(TalkType::getName).collect(toList()))); nextCell().setCellValue(String.join(", ", timeslot.getTagSet())); } autoSizeColumnsWithHeader(); }
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()); } }
/** * this method writes the data into sheet * * @param sheet * sheet of embedded excel * @param categoryData * category values * @param valuesData * data values * @since POI 4.0.0 */ protected void fillSheet(XSSFSheet sheet, XDDFDataSource<?> categoryData, XDDFNumericalDataSource<?> valuesData) { int numOfPoints = categoryData.getPointCount(); for (int i = 0; i < numOfPoints; i++) { XSSFRow row = this.getRow(sheet, i + 1); // first row is for title this.getCell(row, categoryData.getColIndex()).setCellValue(categoryData.getPointAt(i).toString()); this.getCell(row, valuesData.getColIndex()).setCellValue(valuesData.getPointAt(i).doubleValue()); } }
protected void writeIntConstraintParameterLine(String name, int value, String constraintDescription) { nextRow(); nextHeaderCell(name); XSSFCell weightCell = nextCell(); weightCell.setCellValue(value); nextHeaderCell(constraintDescription); }
private void writeAirportList() { nextSheet("Airports", 1, 1, false); nextRow(); nextHeaderCell("Code"); nextHeaderCell("Name"); nextHeaderCell("Latitude"); nextHeaderCell("Longitude"); for (Airport airport : solution.getAirportList()) { nextRow(); nextCell().setCellValue(airport.getCode()); nextCell().setCellValue(airport.getName()); nextCell().setCellValue(airport.getLatitude()); nextCell().setCellValue(airport.getLongitude()); } autoSizeColumnsWithHeader(); }
private void writeRooms() { nextSheet("Rooms", 1, 1, false); nextRow(); nextHeaderCell("Name"); nextHeaderCell("Capacity"); for (Room room : solution.getRoomList()) { nextRow(); nextCell().setCellValue(room.getName()); nextCell().setCellValue(room.getCapacity()); } autoSizeColumnsWithHeader(); }
/** * Set a date value for the cell. Excel treats dates as numeric so you will need to format the cell as * a date. * * @param value the date value to set this cell to. For formulas we'll set the * precalculated value, for numerics we'll set its value. For other types we * will change the cell to a numeric cell and set its value. */ @Override public void setCellValue(Date value) { if(value == null) { setCellType(CellType.BLANK); return; } boolean date1904 = getSheet().getWorkbook().isDate1904(); setCellValue(DateUtil.getExcelDate(value, date1904)); }
/** * set sheet title in excel file * * @param title * title of sheet * @param column * column index * @return return cell reference * @since POI 4.0.0 */ public CellReference setSheetTitle(String title, int column) { XSSFSheet sheet = getSheet(); XSSFRow row = this.getRow(sheet, 0); XSSFCell cell = this.getCell(row, column); cell.setCellValue(title); this.updateSheetTable(sheet.getTables().get(0).getCTTable(), title, column); return new CellReference(sheet.getSheetName(), 0, column, true, true); }
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(); }
private void writePersons() { nextSheet("Persons", 1, 0, false); nextRow(); nextHeaderCell("Full name"); for (Person person : solution.getPersonList()) { nextRow(); nextCell().setCellValue(person.getFullName()); } autoSizeColumnsWithHeader(); }
private void writeSkillList() { nextSheet("Skills", 1, 1, false); nextRow(); nextHeaderCell("Name"); for (Skill skill : solution.getSkillList()) { nextRow(); nextCell().setCellValue(skill.getName()); } autoSizeColumnsWithHeader(); }
private void writeTimeGrainsHoursVertically(int minimumInterval) { int mergeStart = -1; for (TimeGrain timeGrain : solution.getTimeGrainList()) { if (timeGrain.getGrainIndex() % (Math.ceil(minimumInterval * 1.0 / TimeGrain.GRAIN_LENGTH_IN_MINUTES)) == 0) { if (mergeStart > 0) { currentSheet.addMergedRegion(new CellRangeAddress(mergeStart, currentRowNumber, 0, 0)); } nextRow(); nextCell().setCellValue(timeGrain.getDateTimeString()); mergeStart = currentRowNumber; } else { nextRow(); } } if (mergeStart < currentRowNumber) { currentSheet.addMergedRegion(new CellRangeAddress(mergeStart, currentRowNumber, 0, 0)); } }