List of usage examples for org.apache.poi.ss.usermodel Sheet setColumnWidth
void setColumnWidth(int columnIndex, int width);
The maximum column width for an individual cell is 255 characters.
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.VendorPOXlsReport.java
License:Apache License
public void writeProjectDataForTradosMatches(Workbook p_workbook, HashMap p_projectMap, IntHolder p_row, MyData p_data) throws Exception { Sheet theSheet = p_data.tradosSheet; ArrayList projects = new ArrayList(p_projectMap.keySet()); SortUtil.sort(projects);//w w w. j av a 2s . com Iterator projectIter = projects.iterator(); while (projectIter.hasNext()) { String jobName = (String) projectIter.next(); boolean isWrongJob = p_data.wrongJobNames.contains(jobName); HashMap localeMap = (HashMap) p_projectMap.get(jobName); ArrayList locales = new ArrayList(localeMap.keySet()); SortUtil.sort(locales); Iterator localeIter = locales.iterator(); BigDecimal projectTotalWordCountCost = new BigDecimal(BIG_DECIMAL_ZERO_STRING); while (localeIter.hasNext()) { int row = p_row.getValue(); int col = 0; Row theRow = getRow(theSheet, row); String localeName = (String) localeIter.next(); ProjectWorkflowData data = (ProjectWorkflowData) localeMap.get(localeName); CellStyle temp_dateStyle = getDateStyle(p_workbook); CellStyle temp_moneyStyle = getMoneyStyle(p_workbook); CellStyle temp_normalStyle = getContentStyle(p_workbook); // WritableCellFormat temp_wordCountValueRightFormat = // wordCountValueRightFormat; if (data.wasExportFailed) { temp_dateStyle = getFailedDateStyle(p_workbook); temp_moneyStyle = getFailedMoneyStyle(p_workbook); temp_normalStyle = getRedCellStyle(p_workbook); } Cell cell_A = getCell(theRow, col++); cell_A.setCellValue(data.jobId); Cell cell_B = getCell(theRow, col++); cell_B.setCellValue(data.jobName); if (isWrongJob) { cell_A.setCellStyle(getWrongJobStyle(p_workbook)); cell_B.setCellStyle(getWrongJobStyle(p_workbook)); } else { cell_A.setCellStyle(temp_normalStyle); ; cell_B.setCellStyle(temp_normalStyle); } theSheet.setColumnWidth(col - 2, 5 * 256); theSheet.setColumnWidth(col - 1, 50 * 256); Cell cell_C = getCell(theRow, col++); cell_C.setCellValue(data.poNumber); cell_C.setCellStyle(temp_normalStyle); // PO number Cell cell_D = getCell(theRow, col++); cell_D.setCellValue(data.projectDesc); cell_D.setCellStyle(temp_normalStyle); theSheet.setColumnWidth(col - 1, 22 * 256); /* data.creationDate.toString())); */ Cell cell_E = getCell(theRow, col++); cell_E.setCellValue(data.creationDate); cell_E.setCellStyle(temp_dateStyle); theSheet.setColumnWidth(col - 1, 15 * 256); Cell cell_F = getCell(theRow, col++); cell_F.setCellValue(data.targetLang); cell_F.setCellStyle(temp_normalStyle); Cell cell_G = getCell(theRow, col++); cell_G.setCellValue(data.trados100WordCount); cell_G.setCellStyle(temp_normalStyle); int numwidth = 10; theSheet.setColumnWidth(col - 1, numwidth * 256); Cell cell_H = getCell(theRow, col++); cell_H.setCellValue(data.trados95to99WordCount); cell_H.setCellStyle(temp_normalStyle); theSheet.setColumnWidth(col - 1, numwidth * 256); Cell cell_I = getCell(theRow, col++); cell_I.setCellValue(data.trados85to94WordCount); cell_I.setCellStyle(temp_normalStyle); theSheet.setColumnWidth(col - 1, numwidth * 256); Cell cell_J = getCell(theRow, col++); cell_J.setCellValue(data.trados75to84WordCount); cell_J.setCellStyle(temp_normalStyle); theSheet.setColumnWidth(col - 1, numwidth * 256); Cell cell_K = getCell(theRow, col++); cell_K.setCellValue(data.tradosNoMatchWordCount + data.trados50to74WordCount); cell_K.setCellStyle(temp_normalStyle); theSheet.setColumnWidth(col - 1, numwidth * 256); Cell cell_L = getCell(theRow, col++); cell_L.setCellValue(data.tradosRepsWordCount); cell_L.setCellStyle(temp_normalStyle); theSheet.setColumnWidth(col - 1, numwidth * 256); if (p_data.headers[0] != null) { Cell cell_InContext = getCell(theRow, col++); cell_InContext.setCellValue(data.tradosInContextMatchWordCount); cell_InContext.setCellStyle(temp_normalStyle); theSheet.setColumnWidth(col - 1, numwidth * 256); } Cell cell_Total = getCell(theRow, col++); cell_Total.setCellValue(data.tradosTotalWordCount); cell_Total.setCellStyle(temp_normalStyle); theSheet.setColumnWidth(col - 1, numwidth * 256); int moneywidth = 12; Cell cell_100Cost = getCell(theRow, col++); cell_100Cost.setCellValue(asDouble(data.trados100WordCountCost)); cell_100Cost.setCellStyle(temp_moneyStyle); theSheet.setColumnWidth(col - 1, moneywidth * 256); Cell cell_95_99 = getCell(theRow, col++); cell_95_99.setCellValue(asDouble(data.trados95to99WordCountCost)); cell_95_99.setCellStyle(temp_moneyStyle); theSheet.setColumnWidth(col - 1, moneywidth * 256); Cell cell_85_94 = getCell(theRow, col++); cell_85_94.setCellValue(asDouble(data.trados85to94WordCountCost)); cell_85_94.setCellStyle(temp_moneyStyle); theSheet.setColumnWidth(col - 1, moneywidth * 256); Cell cell_75_84 = getCell(theRow, col++); cell_75_84.setCellValue(asDouble(data.trados75to84WordCountCost)); cell_75_84.setCellStyle(temp_moneyStyle); theSheet.setColumnWidth(col - 1, moneywidth * 256); Cell cell_NoMatch = getCell(theRow, col++); cell_NoMatch.setCellValue(asDouble(data.tradosNoMatchWordCountCost)); cell_NoMatch.setCellStyle(temp_moneyStyle); theSheet.setColumnWidth(col - 1, moneywidth * 256); Cell cell_Reps = getCell(theRow, col++); cell_Reps.setCellValue(asDouble(data.tradosRepsWordCountCost)); cell_Reps.setCellStyle(temp_moneyStyle); theSheet.setColumnWidth(col - 1, moneywidth * 256); if (p_data.headers[0] != null) { Cell cell_InContext = getCell(theRow, col++); cell_InContext.setCellValue(asDouble(data.tradosInContextWordCountCost)); cell_InContext.setCellStyle(temp_moneyStyle); theSheet.setColumnWidth(col - 1, moneywidth * 256); } Cell cell_TotalCost = getCell(theRow, col++); cell_TotalCost.setCellValue(asDouble(data.tradosTotalWordCountCost)); cell_TotalCost.setCellStyle(temp_moneyStyle); theSheet.setColumnWidth(col - 1, moneywidth * 256); p_row.inc(); } } p_row.inc(); p_row.inc(); addTotalsForTradosMatches(p_workbook, p_data, p_row, bundle); }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.VendorPOXlsReport.java
License:Apache License
private void writeParamsSheet(Workbook p_workbook, Sheet paramsSheet, MyData p_data, HttpServletRequest p_request) throws Exception { Row firRow = getRow(paramsSheet, 0); Row secRow = getRow(paramsSheet, 1); Row thirRow = getRow(paramsSheet, 2); Cell cell_A_Title = getCell(firRow, 0); cell_A_Title.setCellValue(bundle.getString("lb_report_criteria")); cell_A_Title.setCellStyle(getContentStyle(p_workbook)); paramsSheet.setColumnWidth(0, 50 * 256); Cell cell_A_Header = getCell(secRow, 0); if (p_data.wantsAllProjects) { cell_A_Header.setCellValue(bundle.getString("lb_selected_projects") + " " + bundle.getString("all")); cell_A_Header.setCellStyle(getContentStyle(p_workbook)); } else {/*from w w w . jav a 2 s .c om*/ cell_A_Header.setCellValue(bundle.getString("lb_selected_projects")); cell_A_Header.setCellStyle(getContentStyle(p_workbook)); Iterator<Long> iter = p_data.projectIdList.iterator(); int r = 2; while (iter.hasNext()) { Long pid = (Long) iter.next(); String projectName = "??"; try { Project p = ServerProxy.getProjectHandler().getProjectById(pid.longValue()); projectName = p.getName(); } catch (Exception e) { } String v = projectName + " (" + bundle.getString("lb_report_id") + "=" + pid.toString() + ")"; Row theRow = getRow(paramsSheet, r); Cell cell_A = getCell(theRow, 0); cell_A.setCellValue(v); cell_A.setCellStyle(getContentStyle(p_workbook)); r++; } } // add the date criteria String paramCreateDateStartCount = p_request.getParameter(JobSearchConstants.CREATION_START); // String paramCreateDateStartOpts = p_request // .getParameter(JobSearchConstants.CREATION_START_OPTIONS); String paramCreateDateEndCount = p_request.getParameter(JobSearchConstants.CREATION_END); // String paramCreateDateEndOpts = p_request // .getParameter(JobSearchConstants.CREATION_END_OPTIONS); Cell cell_B_Header = getCell(secRow, 1); cell_B_Header.setCellValue(bundle.getString("lb_from") + ":"); cell_B_Header.setCellStyle(getContentStyle(p_workbook)); // String fromMsg = paramCreateDateStartCount // + " " // + getDateCritieraConditionValue( // paramCreateDateStartOpts); // String untilMsg = paramCreateDateEndCount // + " " // + getDateCritieraConditionValue( // paramCreateDateEndOpts); Cell cell_B = getCell(thirRow, 1); cell_B.setCellValue(paramCreateDateStartCount); cell_B.setCellStyle(getContentStyle(p_workbook)); Cell cell_C_Header = getCell(secRow, 2); cell_C_Header.setCellValue(bundle.getString("lb_until") + ":"); cell_C_Header.setCellStyle(getContentStyle(p_workbook)); Cell cell_C = getCell(thirRow, 2); cell_C.setCellValue(paramCreateDateEndCount); cell_C.setCellStyle(getContentStyle(p_workbook)); // add the target lang criteria Cell cell_D_Header = getCell(secRow, 3); if (p_data.wantsAllTargetLangs) { cell_D_Header.setCellValue(bundle.getString("lb_selected_langs") + " " + bundle.getString("all")); cell_D_Header.setCellStyle(getContentStyle(p_workbook)); } else { cell_D_Header.setCellValue(bundle.getString("lb_selected_langs")); cell_D_Header.setCellStyle(getContentStyle(p_workbook)); Iterator<String> iter = p_data.targetLangList.iterator(); int r = 2; LocaleManagerLocal manager = new LocaleManagerLocal(); while (iter.hasNext()) { String lang = iter.next(); Row theRow = getRow(paramsSheet, r); Cell cell_D = getCell(theRow, 3); cell_D.setCellValue(manager.getLocaleById(Long.valueOf(lang)).toString()); cell_D.setCellStyle(getContentStyle(p_workbook)); r++; } paramsSheet.setColumnWidth(3, 15 * 256); } }
From source file:com.griffinslogistics.document.excel.BookLabelGenerator.java
private static void generate(XSSFWorkbook workbook, BookLabelModel bookLabelModel) { Map<String, CellStyle> styles = createStyles(workbook); String title = bookLabelModel.getTitle().replace("/", "-"); bookLabelModel.setTitle(title);/*w w w . ja v a2 s . c o m*/ // Sheet sheet = workbook.createSheet(bookLabelModel.getBookNumber() + " " + bookLabelModel.getTitle()); Sheet sheet = workbook.createSheet(); for (int i = 0; i < 20; i++) { sheet.createRow(i); } generateHeaders(sheet, styles); generateAddress(sheet, styles, bookLabelModel); generateClient(sheet, styles, bookLabelModel); generateTransportation(sheet, styles, bookLabelModel); generateTitle(sheet, styles, bookLabelModel); generateCountPerBox(sheet, styles, bookLabelModel); generateCountPerAddress(sheet, styles, bookLabelModel); sheet.setColumnWidth(1, 20000); sheet.setColumnWidth(4, 20000); sheet.autoSizeColumn(0, false); sheet.autoSizeColumn(3, false); sheet.getPrintSetup().setLandscape(true); sheet.getPrintSetup().setPaperSize(XSSFPrintSetup.A4_PAPERSIZE); sheet.setFitToPage(true); }
From source file:com.griffinslogistics.excel.BDLGenerator.java
public static void generateAll(OutputStream outputStream, Map<String, List<BookBoxModel>> bookBoxModelsForTransportation, Pulsiodetails pulsioDetails, String packageNumber) {/*from ww w.j a va 2 s.co m*/ try { Workbook workbook = new HSSFWorkbook(); Map<String, CellStyle> styles = createStyles(workbook); for (String bookspackageNumber : bookBoxModelsForTransportation.keySet()) { Sheet sheet = workbook.createSheet(bookspackageNumber); //Default sheet styles sheet.setDisplayGridlines(false); sheet.setPrintGridlines(false); sheet.getPrintSetup().setLandscape(true); sheet.setFitToPage(true); sheet.setHorizontallyCenter(true); sheet.setDefaultRowHeight((short) 300); sheet.setDefaultColumnWidth(15); sheet.setColumnWidth(1, 6000); sheet.setColumnWidth(5, 3000); sheet.setColumnWidth(6, 3000); sheet.setColumnWidth(7, 3000); sheet.setColumnWidth(8, 3000); // Generate header part insertPulsioImage(workbook, sheet, pulsioDetails); insertDate(sheet, styles.get("title")); insertContacts(sheet, styles.get("pulsioName"), styles.get("contacts"), pulsioDetails); insertTitle(sheet, styles.get("title")); // Generate table part insertTableHeaders(sheet, styles.get("tableHeadersLeft"), styles.get("tableHeadersMiddle"), styles.get("tableHeadersRight")); List<BookBoxModel> bookBoxModels = bookBoxModelsForTransportation.get(bookspackageNumber); int index = insertTableBody(sheet, styles.get("tableBodyLeft"), styles.get("tableBodyMiddle"), styles.get("tableBodyRight"), styles.get("tableFooters"), bookBoxModels); String deliveryAddress = bookBoxModels.get(0).getDeliveryAddress(); String client = bookBoxModels.get(0).getClient(); insertFooter(sheet, styles.get("footer"), index, bookspackageNumber, deliveryAddress, client); } workbook.write(outputStream); } catch (FileNotFoundException ex) { logger.log(Level.SEVERE, null, ex); } catch (IOException ex) { logger.log(Level.SEVERE, null, ex); } }
From source file:com.griffinslogistics.excel.BDLGenerator.java
public static OutputStream generateSingle(OutputStream outputStream, List<BookBoxModel> bookBoxModels, Pulsiodetails pulsiodetails, String packageNumber) { try {/* w ww . java 2 s . c o m*/ Workbook workbook = new HSSFWorkbook(); Map<String, CellStyle> styles = createStyles(workbook); Sheet sheet = workbook.createSheet("Bon de livraison"); //Default sheet styles sheet.setDisplayGridlines(false); sheet.setPrintGridlines(false); sheet.getPrintSetup().setLandscape(true); sheet.setFitToPage(true); sheet.setHorizontallyCenter(true); sheet.setDefaultRowHeight((short) 300); sheet.setDefaultColumnWidth(15); sheet.setColumnWidth(1, 6000); sheet.setColumnWidth(5, 3000); sheet.setColumnWidth(6, 3000); sheet.setColumnWidth(7, 3000); sheet.setColumnWidth(8, 3000); // Generate header part insertPulsioImage(workbook, sheet, pulsiodetails); insertDate(sheet, styles.get("title")); insertContacts(sheet, styles.get("pulsioName"), styles.get("contacts"), pulsiodetails); insertTitle(sheet, styles.get("title")); // Generate table part insertTableHeaders(sheet, styles.get("tableHeadersLeft"), styles.get("tableHeadersMiddle"), styles.get("tableHeadersRight")); int index = insertTableBody(sheet, styles.get("tableBodyLeft"), styles.get("tableBodyMiddle"), styles.get("tableBodyRight"), styles.get("tableFooters"), bookBoxModels); String deliveryAddress = bookBoxModels.get(0).getDeliveryAddress(); String client = bookBoxModels.get(0).getClient(); insertFooter(sheet, styles.get("footer"), index, packageNumber, deliveryAddress, client); workbook.write(outputStream); } catch (FileNotFoundException ex) { logger.log(Level.SEVERE, null, ex); } catch (IOException ex) { logger.log(Level.SEVERE, null, ex); } return outputStream; }
From source file:com.griffinslogistics.excel.BookLabelGenerator.java
public static void generateLabel(OutputStream outputStream, BookLabelModel bookLabelModel) { try {/*from ww w.ja v a 2s. co m*/ XSSFWorkbook workbook = new XSSFWorkbook(); Map<String, CellStyle> styles = createStyles(workbook); String title = bookLabelModel.getTitle().replace("/", "-"); bookLabelModel.setTitle(title); Sheet sheet = workbook.createSheet(bookLabelModel.getBookNumber() + " " + bookLabelModel.getTitle()); for (int i = 0; i < 20; i++) { Row row = sheet.createRow(i); if (i != 0 && i != 10) { row.setHeightInPoints(25); } else { row.setHeightInPoints(12); } } //column widths sheet.setColumnWidth(0, 5000); sheet.setColumnWidth(1, 10000); sheet.setColumnWidth(3, 5000); sheet.setColumnWidth(4, 10000); generateHeaders(sheet, styles); generateAddress(sheet, styles, bookLabelModel); generateClient(sheet, styles, bookLabelModel); generateTransportation(sheet, styles, bookLabelModel); generateTitle(sheet, styles, bookLabelModel); generateCountPerBox(sheet, styles, bookLabelModel); generateCountPerAddress(sheet, styles, bookLabelModel); sheet.autoSizeColumn(1); sheet.autoSizeColumn(4); workbook.write(outputStream); } catch (IOException ex) { Logger.getLogger(BookLabelGenerator.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.ideaspymes.proyecttemplate.stock.web.ProductoConsultaBean.java
@Override public Workbook getWorkBook() { Workbook wb = new XSSFWorkbook(); Sheet sheet = wb.createSheet("My Sample Excel"); List<CatalogoProductos> lista = (List<CatalogoProductos>) getDetalles(); sheet.setDefaultRowHeight((short) (sheet.getDefaultRowHeight() * new Short("6"))); org.apache.poi.ss.usermodel.Font fontTitulo = wb.createFont(); fontTitulo.setFontHeightInPoints((short) 12); fontTitulo.setBoldweight(org.apache.poi.ss.usermodel.Font.BOLDWEIGHT_BOLD); org.apache.poi.ss.usermodel.Font fontTituloPricipal = wb.createFont(); fontTituloPricipal.setFontHeightInPoints((short) 22); fontTituloPricipal.setBoldweight(org.apache.poi.ss.usermodel.Font.BOLDWEIGHT_BOLD); DataFormat format = wb.createDataFormat(); CellStyle styleTituloPrincipal = wb.createCellStyle(); styleTituloPrincipal.setFont(fontTituloPricipal); styleTituloPrincipal.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styleTituloPrincipal.setAlignment(CellStyle.ALIGN_CENTER); CellStyle styleTitulo = wb.createCellStyle(); styleTitulo.setFont(fontTitulo);//from w ww. ja va2s . co m styleTitulo.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styleTitulo.setFillForegroundColor(IndexedColors.BLUE_GREY.getIndex()); styleTitulo.setFillPattern(CellStyle.SOLID_FOREGROUND); styleTitulo.setWrapText(true); CellStyle styleNumero = wb.createCellStyle(); styleNumero.setDataFormat(format.getFormat("#,##0")); styleNumero.setWrapText(true); styleNumero.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styleNumero.setAlignment(CellStyle.ALIGN_CENTER); CellStyle styleFecha = wb.createCellStyle(); styleFecha.setDataFormat(format.getFormat("dd/MM/yyyy")); styleFecha.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styleFecha.setAlignment(CellStyle.ALIGN_CENTER); CellStyle style = wb.createCellStyle(); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); style.setWrapText(true); CellStyle styleCenter = wb.createCellStyle(); styleCenter.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styleCenter.setAlignment(CellStyle.ALIGN_CENTER); styleCenter.setWrapText(true); Row rowTitle = sheet.createRow(0); Cell cellTitle = rowTitle.createCell(1); cellTitle.setCellStyle(styleTituloPrincipal); sheet.addMergedRegion(new CellRangeAddress(0, //first row (0-based) 1, //last row (0-based) 1, //first column (0-based) 11 //last column (0-based) )); cellTitle.setCellValue("Listado de Activos"); int i = 2; Row row0 = sheet.createRow(i); row0.setHeight((short) 500); Cell cell1 = row0.createCell(1); cell1.setCellValue("Foto"); cell1.setCellStyle(styleTitulo); Cell cellFecha = row0.createCell(3); cellFecha.setCellValue("Fecha Ingreso"); cellFecha.setCellStyle(styleTitulo); Cell cellFechaCarga = row0.createCell(4); cellFechaCarga.setCellValue("Fecha Carga"); cellFechaCarga.setCellStyle(styleTitulo); Cell cell3 = row0.createCell(5); cell3.setCellValue("Nombre"); cell3.setCellStyle(styleTitulo); Cell cell4 = row0.createCell(6); cell4.setCellValue("Cdigo"); cell4.setCellStyle(styleTitulo); Cell cell5 = row0.createCell(7); cell5.setCellValue("Descripcin"); cell5.setCellStyle(styleTitulo); Cell cell6 = row0.createCell(8); cell6.setCellValue("Es Regalo?"); cell6.setCellStyle(styleTitulo); Cell cell7 = row0.createCell(9); cell7.setCellValue("Familia"); cell7.setCellStyle(styleTitulo); Cell cell8 = row0.createCell(10); cell8.setCellValue("Ubicaciones"); cell8.setCellStyle(styleTitulo); Cell cell9 = row0.createCell(11); cell9.setCellValue("Stock"); cell9.setCellStyle(styleTitulo); for (CatalogoProductos cp : lista) { int indexFila = i + 1; if (cp.getImagen() != null) { int pictureIdx = wb.addPicture(cp.getImagen(), Workbook.PICTURE_TYPE_PNG); CreationHelper helper = wb.getCreationHelper(); //Creates the top-level drawing patriarch. Drawing drawing = sheet.createDrawingPatriarch(); //Create an anchor that is attached to the worksheet ClientAnchor anchor = helper.createClientAnchor(); //set top-left corner for the image anchor.setCol1(1); anchor.setRow1(indexFila); //Creates a picture Picture pict = drawing.createPicture(anchor, pictureIdx); //Reset the image to the original size pict.resize(0.4); } Row row1 = sheet.createRow(indexFila); row1.setHeightInPoints(80f); Cell cellColFecha = row1.createCell(3); if (cp.getFecha() != null) { cellColFecha.setCellValue(cp.getFecha()); cellColFecha.setCellStyle(styleFecha); } else { cellColFecha.setCellValue(""); cellColFecha.setCellStyle(styleFecha); } Cell cellColFechaCarga = row1.createCell(4); if (cp.getFechaCarga() != null) { cellColFechaCarga.setCellValue(cp.getFechaCarga()); cellColFechaCarga.setCellStyle(styleFecha); } else { cellColFechaCarga.setCellValue(""); cellColFechaCarga.setCellStyle(styleFecha); } Cell cellCol1 = row1.createCell(5); cellCol1.setCellValue(cp.getProducto()); cellCol1.setCellStyle(style); Cell cellCol2 = row1.createCell(6); cellCol2.setCellValue(cp.getCodigo()); cellCol2.setCellStyle(styleNumero); Cell cellCol3 = row1.createCell(7); cellCol3.setCellValue(cp.getDescripcion()); cellCol3.setCellStyle(style); Cell cellCol4 = row1.createCell(8); cellCol4.setCellValue(cp.isEsRegalo() ? "SI" : "NO"); cellCol4.setCellStyle(styleCenter); Cell cellCol5 = row1.createCell(9); cellCol5.setCellValue(cp.getFamilia()); cellCol5.setCellStyle(style); Cell cellCol6 = row1.createCell(10); cellCol6.setCellValue(cp.getUbicaciones()); cellCol6.setCellStyle(style); Cell cellCol7 = row1.createCell(11); cellCol7.setCellValue(cp.getStock()); cellCol7.setCellStyle(styleNumero); i++; } sheet.setColumnWidth(1, 4000); sheet.setColumnWidth(2, 0); sheet.setColumnWidth(3, 4000); sheet.setColumnWidth(4, 4000); sheet.setColumnWidth(5, 10000); sheet.setColumnWidth(6, 3000); sheet.setColumnWidth(7, 10000); sheet.setColumnWidth(8, 3500); sheet.setColumnWidth(9, 6000); sheet.setColumnWidth(10, 10000); sheet.setColumnWidth(11, 2000); return wb; }
From source file:com.inet.web.service.spi.download.ExportEmailWriterSpiService.java
License:Open Source License
/** * /* www . j a v a2 s .c o m*/ * @param ws * @throws WriteException */ private void writeHeaderEmail(Sheet sheet) { // header row Row headerRow = sheet.createRow(index++); headerRow.setHeightInPoints(30); sheet.setColumnWidth(STT, 5 * 256); headerRow.createCell(STT).setCellValue("STT"); sheet.setColumnWidth(FULL_NAME, 25 * 256); headerRow.createCell(FULL_NAME).setCellValue("FULL NAME"); sheet.setColumnWidth(EMAIL, 15 * 256); headerRow.createCell(EMAIL).setCellValue("EMAIL"); sheet.setColumnWidth(LAST_NAME, 15 * 256); headerRow.createCell(LAST_NAME).setCellValue("LAST NAME"); sheet.setColumnWidth(MIDDLE_NAME, 15 * 256); headerRow.createCell(MIDDLE_NAME).setCellValue("MIDDLE_NAME"); sheet.setColumnWidth(FIRST_NAME, 10 * 256); headerRow.createCell(FIRST_NAME).setCellValue("FIRST_NAME"); sheet.setColumnWidth(QUOTA, 6 * 256); headerRow.createCell(QUOTA).setCellValue("QUOTA"); sheet.setColumnWidth(TITLE, 10 * 256); headerRow.createCell(TITLE).setCellValue("TITLE"); sheet.setColumnWidth(TELEPHONE, 10 * 256); headerRow.createCell(TELEPHONE).setCellValue("TELEPHONE"); sheet.setColumnWidth(MOBILE, 12 * 256); headerRow.createCell(MOBILE).setCellValue("MOBILE"); }
From source file:com.ipcglobal.fredimport.xls.DistinctCategoriesSpreadsheet.java
License:Apache License
/** * Process column widths.//from w w w . jav a2 s . c o m * * @param sheet the sheet * @param hdrWidthItems the hdr width items * @throws Exception the exception */ private void processColumnWidths(Sheet sheet, List<XlsDefItem> hdrWidthItems) throws Exception { int colNum = 0; for (XlsDefItem hdrWidthItem : hdrWidthItems) sheet.setColumnWidth(colNum++, hdrWidthItem.getWidth() * COLUMN_WIDTH_FACTOR); }
From source file:com.jeans.iservlet.action.asset.AssetExportAction.java
private void generateSheetHeader(Sheet sheet, boolean hardware) { // //from w ww . j av a 2 s.com // ?10?? Font font = sheet.getWorkbook().createFont(); font.setBoldweight(Font.BOLDWEIGHT_BOLD); font.setFontName(""); font.setFontHeightInPoints((short) 10); // ????????? CellStyle cellStyle = sheet.getWorkbook().createCellStyle(); cellStyle.setAlignment(CellStyle.ALIGN_CENTER); cellStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER); cellStyle.setFont(font); cellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("text")); cellStyle.setWrapText(false); // 20 Row row = sheet.createRow(0); row.setHeightInPoints(20); Cell cell = null; if (hardware) { for (int i = 0; i < 20; i++) { cell = row.createCell(i, Cell.CELL_TYPE_STRING); cell.setCellStyle(cellStyle); cell.setCellValue(HARDWARE_HEADERS[i]); sheet.setColumnWidth(i, HARDWARE_HEADERS_WIDTH[i] * 256); } } else { for (int i = 0; i < 14; i++) { cell = row.createCell(i, Cell.CELL_TYPE_STRING); cell.setCellStyle(cellStyle); cell.setCellValue(SOFTWARE_HEADERS[i]); sheet.setColumnWidth(i, SOFTWARE_HEADERS_WIDTH[i] * 256); } } }