List of usage examples for org.apache.poi.hssf.usermodel HSSFCell setCellValue
@SuppressWarnings("fallthrough") public void setCellValue(boolean value)
From source file:com.qcadoo.mes.assignmentToShift.print.xls.AssignmentToShiftXlsService.java
License:Open Source License
private void createHeaderForAuthor(final HSSFSheet sheet, final Locale locale, final Entity entity) { HSSFRow headerAuthorLine = sheet.createRow(1); String shift = translationService.translate(COLUMN_HEADER_SHIFT, locale) + " " + entity.getBelongsToField(SHIFT).getStringField(NAME); String user = translationService.translate(COLUMN_HEADER_AUTHOR, locale) + " " + entity.getField(CREATE_USER).toString(); String date = translationService.translate(COLUMN_HEADER_UPDATE_DATE, locale) + " " + DateFormat.getDateInstance().format(entity.getField(UPDATE_DATE)); HSSFCell cellAuthorLine0 = headerAuthorLine.createCell(0); cellAuthorLine0.setCellValue(shift); HSSFCell cellAuthorLine3 = headerAuthorLine.createCell(3); cellAuthorLine3.setCellValue(date);//from w ww . ja v a2s . com HSSFCell cellAuthorLine6 = headerAuthorLine.createCell(6); cellAuthorLine6.setCellValue(user); headerAuthorLine.setHeightInPoints(30); assignmentToShiftXlsStyleHelper.addMarginsAndStylesForAuthor(sheet, 1, assignmentToShiftXlsHelper.getNumberOfDaysBetweenGivenDates(entity)); }
From source file:com.qcadoo.mes.assignmentToShift.print.xls.AssignmentToShiftXlsService.java
License:Open Source License
private void createHeaderForAssignmentToShift(final HSSFSheet sheet, final Locale locale, final Entity entity) { List<DateTime> days = assignmentToShiftXlsHelper.getDaysBetweenGivenDates(entity); if (days != null) { HSSFRow headerAssignmentToShift = sheet.createRow(3); String occupationType = translationService.translate(COLUMN_HEADER_OCCUPATIONTYPE, locale); HSSFCell cell0 = headerAssignmentToShift.createCell(0); cell0.setCellValue(occupationType); int columnNumber = 1; for (DateTime day : days) { HSSFCell cellDay = headerAssignmentToShift.createCell(columnNumber); cellDay.setCellValue(translationService.translate(COLUMN_HEADER_DAY, locale, DateFormat.getDateInstance().format(new Date(day.getMillis())))); columnNumber += 3;/*w w w .j a v a 2 s. com*/ } headerAssignmentToShift.setHeightInPoints(14); assignmentToShiftXlsStyleHelper.addMarginsAndStylesForAssignmentToShift(sheet, 3, assignmentToShiftXlsHelper.getNumberOfDaysBetweenGivenDates(entity)); } }
From source file:com.qcadoo.mes.assignmentToShift.print.xls.AssignmentToShiftXlsService.java
License:Open Source License
private int fillColumnWithStaffForWorkOnLine(final HSSFSheet sheet, int rowNum, final Entity assignmentToShiftReport, final List<DateTime> days, final List<Entity> productionLines, final Entity dictionaryItem) { if ((assignmentToShiftReport != null) && (days != null) && (productionLines != null)) { for (Entity productionLine : productionLines) { int rowNumFromLastSection = rowNum; int numberOfColumnsForWorkers = getNumberOfRowsForWorkers(assignmentToShiftReport, days, productionLine, dictionaryItem); for (int i = 0; i < numberOfColumnsForWorkers; i++) { HSSFRow row = sheet.createRow(rowNum); rowNum++;//w w w . j a va2s .c o m } String productionLineValue = null; if (productionLine.getStringField(PLACE) == null) { productionLineValue = productionLine.getStringField(NUMBER); } else { productionLineValue = productionLine.getStringField(NUMBER) + "-" + productionLine.getStringField(ProductionLineFields.PLACE); } HSSFRow firstRowInSection = null; if (sheet.getRow(rowNumFromLastSection) == null) { firstRowInSection = sheet.createRow(rowNumFromLastSection); rowNum++; } else { firstRowInSection = sheet.getRow(rowNumFromLastSection); } HSSFCell cell = firstRowInSection.createCell(0); cell.setCellValue(productionLineValue); sheet.addMergedRegion(new CellRangeAddress(rowNumFromLastSection, rowNum - 1, 0, 0)); int columnNumber = 1; int maxLength = 0; for (DateTime day : days) { Entity assignmentToShift = assignmentToShiftXlsHelper .getAssignmentToShift(assignmentToShiftReport.getBelongsToField(SHIFT), day.toDate()); if (assignmentToShift == null) { columnNumber += 3; continue; } List<Entity> staffs = assignmentToShiftXlsHelper.getStaffsList(assignmentToShift, dictionaryItem.getStringField(NAME), productionLine); if (staffs.isEmpty()) { columnNumber += 3; continue; } String staffsValue = assignmentToShiftXlsHelper.getListOfWorkers(staffs); List<String> workers = assignmentToShiftXlsHelper.getListOfWorker(staffs); int rowIndex = rowNumFromLastSection; for (String worker : workers) { sheet.getRow(rowIndex).createCell(columnNumber).setCellValue(worker); rowIndex++; } if (workers.isEmpty()) { sheet.getRow(rowIndex).createCell(columnNumber).setCellValue(" "); } if (maxLength < staffsValue.length()) { maxLength = staffsValue.length(); } // row.setHeightInPoints(assignmentToShiftXlsStyleHelper.getHeightForRow(maxLength, 22, 14)); columnNumber += 3; } for (int i = rowNumFromLastSection; i < rowNum; i++) { assignmentToShiftXlsStyleHelper.addMarginsAndStylesForSeries(sheet, i, assignmentToShiftXlsHelper.getNumberOfDaysBetweenGivenDates(assignmentToShiftReport)); } } } return rowNum; }
From source file:com.qcadoo.mes.assignmentToShift.print.xls.AssignmentToShiftXlsService.java
License:Open Source License
private int fillColumnWithStaffForOtherTypes(final HSSFSheet sheet, int rowNum, final Entity assignmentToShiftReport, final List<DateTime> days, final Entity occupationType) { if ((assignmentToShiftReport != null) && (days != null) && (occupationType != null)) { int rowNumFromLastSection = rowNum; int numberOfColumnsForWorkers = getNumberOfRowsForWorkersForOtherTypes(assignmentToShiftReport, days, occupationType);/*from w w w. ja v a 2 s.c om*/ for (int i = 0; i < numberOfColumnsForWorkers; i++) { HSSFRow row = sheet.createRow(rowNum); rowNum++; } String occupationTypeValue = occupationType.getStringField(NAME); HSSFRow firstRowInSection = null; if (sheet.getRow(rowNumFromLastSection) == null) { firstRowInSection = sheet.createRow(rowNumFromLastSection); rowNum++; } else { firstRowInSection = sheet.getRow(rowNumFromLastSection); } HSSFCell cell = firstRowInSection.createCell(0); cell.setCellValue(occupationTypeValue); sheet.addMergedRegion(new CellRangeAddress(rowNumFromLastSection, rowNum - 1, 0, 0)); int columnNumber = 1; int maxLength = 0; for (DateTime day : days) { Entity assignmentToShift = assignmentToShiftXlsHelper .getAssignmentToShift(assignmentToShiftReport.getBelongsToField(SHIFT), day.toDate()); if (assignmentToShift == null) { columnNumber += 3; continue; } List<Entity> staffs = assignmentToShiftXlsHelper.getStaffsList(assignmentToShift, occupationType.getStringField(NAME), null); List<String> workers = Lists.newArrayList(); if (OccupationType.OTHER_CASE.getStringValue() .equals(occupationType.getStringField(TECHNICAL_CODE))) { workers = assignmentToShiftXlsHelper.getListOfWorkerWithOtherCases(staffs); } else { workers = assignmentToShiftXlsHelper.getListOfWorker(staffs); } int rowIndex = rowNumFromLastSection; for (String worker : workers) { sheet.getRow(rowIndex).createCell(columnNumber).setCellValue(worker); rowIndex++; } if (workers.isEmpty()) { sheet.getRow(rowIndex).createCell(columnNumber).setCellValue(" "); } columnNumber += 3; } for (int i = rowNumFromLastSection; i < rowNum; i++) { assignmentToShiftXlsStyleHelper.addMarginsAndStylesForSeries(sheet, i, assignmentToShiftXlsHelper.getNumberOfDaysBetweenGivenDates(assignmentToShiftReport)); } } return rowNum; }
From source file:com.qcadoo.mes.materialFlow.print.xls.MaterialFlowXlsService.java
License:Open Source License
@Override protected void addHeader(final HSSFSheet sheet, final Locale locale, final Entity entity) { HSSFRow header = sheet.createRow(0); HSSFCell cell0 = header.createCell(0); cell0.setCellValue( translationService.translate("materialFlow.materialFlow.report.columnHeader.number", locale)); xlsHelper.setCellStyle(sheet, cell0); HSSFCell cell1 = header.createCell(1); cell1.setCellValue(/* w w w.java 2 s . c o m*/ translationService.translate("materialFlow.materialFlow.report.columnHeader.name", locale)); xlsHelper.setCellStyle(sheet, cell1); HSSFCell cell2 = header.createCell(2); cell2.setCellValue( translationService.translate("materialFlow.materialFlow.report.columnHeader.quantity", locale)); xlsHelper.setCellStyle(sheet, cell2); HSSFCell cell3 = header.createCell(3); cell3.setCellValue( translationService.translate("materialFlow.materialFlow.report.columnHeader.unit", locale)); xlsHelper.setCellStyle(sheet, cell3); }
From source file:com.qcadoo.mes.materialRequirements.print.xls.MaterialRequirementXlsService.java
License:Open Source License
@Override protected void addHeader(final HSSFSheet sheet, final Locale locale, final Entity materialRequirement) { HSSFRow header = sheet.createRow(0); HSSFCell cell0 = header.createCell(0); cell0.setCellValue(translationService.translate("basic.product.number.label", locale)); xlsHelper.setCellStyle(sheet, cell0); HSSFCell cell1 = header.createCell(1); cell1.setCellValue(translationService.translate("basic.product.name.label", locale)); xlsHelper.setCellStyle(sheet, cell1); HSSFCell cell2 = header.createCell(2); cell2.setCellValue(//from w w w . ja v a 2 s . c o m translationService.translate("technologies.technologyOperationComponent.quantity.label", locale)); xlsHelper.setCellStyle(sheet, cell2); HSSFCell cell3 = header.createCell(3); cell3.setCellValue(translationService.translate("basic.product.unit.label", locale)); xlsHelper.setCellStyle(sheet, cell3); }
From source file:com.qcadoo.mes.qualityControls.print.QualityControlForBatchXlsView.java
License:Open Source License
private void addOrderHeader(final HSSFSheet sheet, final Locale locale) { HSSFRow header = sheet.createRow(0); HSSFCell cell0 = header.createCell(0); cell0.setCellValue( translationService.translate("qualityControls.qualityControl.report.product.number", locale)); xlsHelper.setCellStyle(sheet, cell0); HSSFCell cell1 = header.createCell(1); cell1.setCellValue(translationService.translate( "qualityControlsForBatch.qualityControlsForBatchList.window.mainTab.qualityControlsForBatch.column.batchNr", locale));//from w w w . java 2 s .c o m xlsHelper.setCellStyle(sheet, cell1); HSSFCell cell2 = header.createCell(2); cell2.setCellValue(translationService.translate( "qualityControlsForBatch.qualityControlsForBatchList.window.mainTab.qualityControlsForBatch.column.number", locale)); xlsHelper.setCellStyle(sheet, cell2); HSSFCell cell3 = header.createCell(3); cell3.setCellValue(translationService.translate( "qualityControlsForBatch.qualityControlForBatchDetails.window.mainTab.qualityControlForBatch.controlledQuantity.label", locale)); xlsHelper.setCellStyle(sheet, cell3); HSSFCell cell4 = header.createCell(4); cell4.setCellValue(translationService.translate( "qualityControlsForBatch.qualityControlForBatchDetails.window.mainTab.qualityControlForBatch.rejectedQuantity.label", locale)); xlsHelper.setCellStyle(sheet, cell4); HSSFCell cell5 = header.createCell(5); cell5.setCellValue(translationService.translate( "qualityControlsForBatch.qualityControlForBatchDetails.window.mainTab.qualityControlForBatch.acceptedDefectsQuantity.label", locale)); xlsHelper.setCellStyle(sheet, cell5); }
From source file:com.qcadoo.mes.qualityControls.print.QualityControlForOperationXlsView.java
License:Open Source License
private void addOrderHeader(final HSSFSheet sheet, final Locale locale) { HSSFRow header = sheet.createRow(0); HSSFCell cell0 = header.createCell(0); cell0.setCellValue( translationService.translate("qualityControls.qualityControl.report.operation.number", locale)); xlsHelper.setCellStyle(sheet, cell0); HSSFCell cell1 = header.createCell(1); cell1.setCellValue(translationService.translate( "qualityControlsForOperation.qualityControlForOperationDetails.window.mainTab.qualityControlForOperation.number.label", locale));//from ww w .j a v a 2 s . com xlsHelper.setCellStyle(sheet, cell1); HSSFCell cell2 = header.createCell(2); cell2.setCellValue(translationService.translate( "qualityControlsForOperation.qualityControlForOperationDetails.window.mainTab.qualityControlForOperation.controlResult.label", locale)); xlsHelper.setCellStyle(sheet, cell2); }
From source file:com.qcadoo.mes.qualityControls.print.QualityControlForOrderXlsView.java
License:Open Source License
private void addOrderHeader(final HSSFSheet sheet, final Locale locale) { HSSFRow header = sheet.createRow(0); HSSFCell cell0 = header.createCell(0); cell0.setCellValue( translationService.translate("qualityControls.qualityControl.report.product.number", locale)); xlsHelper.setCellStyle(sheet, cell0); HSSFCell cell1 = header.createCell(1); cell1.setCellValue(translationService.translate( "qualityControls.qualityControlForOrderDetails.window.mainTab.qualityControlForOrder.number.label", locale));/*from w w w .jav a 2 s . c om*/ xlsHelper.setCellStyle(sheet, cell1); HSSFCell cell2 = header.createCell(2); cell2.setCellValue(translationService.translate( "qualityControls.qualityControlForOrderDetails.window.qualityControlForOrder.controlResult.label", locale)); xlsHelper.setCellStyle(sheet, cell2); }
From source file:com.qcadoo.mes.qualityControls.print.QualityControlForUnitXlsView.java
License:Open Source License
private void addOrderHeader(final HSSFSheet sheet, final Locale locale) { HSSFRow header = sheet.createRow(0); HSSFCell cell0 = header.createCell(0); cell0.setCellValue( translationService.translate("qualityControls.qualityControl.report.product.number", locale)); xlsHelper.setCellStyle(sheet, cell0); HSSFCell cell1 = header.createCell(1); cell1.setCellValue(translationService.translate( "qualityControls.qualityControlForUnitDetails.window.mainTab.qualityControlForUnit.number.label", locale));/*from w ww .j av a2 s . co m*/ xlsHelper.setCellStyle(sheet, cell1); HSSFCell cell2 = header.createCell(2); cell2.setCellValue(translationService.translate( "qualityControls.qualityControlForUnitDetails.window.mainTab.qualityControlForUnit.controlledQuantity.label", locale)); xlsHelper.setCellStyle(sheet, cell2); HSSFCell cell3 = header.createCell(3); cell3.setCellValue(translationService.translate( "qualityControls.qualityControlForUnitDetails.window.mainTab.qualityControlForUnit.rejectedQuantity.label", locale)); xlsHelper.setCellStyle(sheet, cell3); HSSFCell cell4 = header.createCell(4); cell4.setCellValue(translationService.translate( "qualityControls.qualityControlForUnitDetails.window.mainTab.qualityControlForUnit.acceptedDefectsQuantity.label", locale)); xlsHelper.setCellStyle(sheet, cell4); }