當前位置: 首頁>>代碼示例>>Java>>正文


Java Cell.setCellStyle方法代碼示例

本文整理匯總了Java中org.apache.poi.ss.usermodel.Cell.setCellStyle方法的典型用法代碼示例。如果您正苦於以下問題:Java Cell.setCellStyle方法的具體用法?Java Cell.setCellStyle怎麽用?Java Cell.setCellStyle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.poi.ss.usermodel.Cell的用法示例。


在下文中一共展示了Cell.setCellStyle方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: buildSheet

import org.apache.poi.ss.usermodel.Cell; //導入方法依賴的package包/類
private void buildSheet(SXSSFWorkbook wb,VariableCategory vc,XSSFCellStyle style){
	String name=vc.getName();
	Sheet sheet=wb.createSheet(name);
	Row row=sheet.createRow(0);
	List<Variable> variables=vc.getVariables();
	for(int i=0;i<variables.size();i++){
		sheet.setColumnWidth(i,4000);
		Cell cell=row.createCell(i);
		Variable var=variables.get(i);
		cell.setCellValue(var.getLabel());
		cell.setCellStyle(style);
	}
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:14,代碼來源:PackageServletHandler.java

示例2: setupTotalCell

import org.apache.poi.ss.usermodel.Cell; //導入方法依賴的package包/類
protected void setupTotalCell(Cell cell, final String propId, final int currentRow, final int startRow, int col) {
    cell.setCellStyle(getCellStyle(propId, currentRow, startRow, col, true));
    final HorizontalAlignment poiAlignment = getGridHolder().getCellAlignment(propId);
    CellUtil.setAlignment(cell, poiAlignment);
    Class<?> propType = getGridHolder().getPropertyType(propId);
    if (isNumeric(propType)) {
        CellRangeAddress cra = new CellRangeAddress(startRow, currentRow - 1, col, col);
        if (isHierarchical()) {
            // 9 & 109 are for sum. 9 means include hidden cells, 109 means exclude.
            // this will show the wrong value if the user expands an outlined category, so
            // we will range value it first
            cell.setCellFormula("SUM(" + cra.formatAsString(hierarchicalTotalsSheet.getSheetName(),
                    true) + ")");
        } else {
            cell.setCellFormula("SUM(" + cra.formatAsString() + ")");
        }
    } else {
        if (0 == col) {
            cell.setCellValue(createHelper.createRichTextString("Total"));
        }
    }
}
 
開發者ID:TFyre,項目名稱:vaadin-gridexport,代碼行數:23,代碼來源:ExcelExport.java

示例3: addTitleToSheet

import org.apache.poi.ss.usermodel.Cell; //導入方法依賴的package包/類
public int addTitleToSheet(ReportTitle reportTitle, Sheet sheet, int row, int firstCol, int lastCol) {
	if (!reportTitle.isShowTitle()) {
		return row;
	}
	Row titleRow = sheet.createRow(row);
	Cell titleCell = titleRow.createCell(firstCol);
	titleCell.setCellType(Cell.CELL_TYPE_STRING);
	titleCell.setCellValue(reportTitle.getTitle());
	CellStyle titleStyle = new TitleStyleBuilder().builder(reportTitle, sheet.getWorkbook());
	titleCell.setCellStyle(titleStyle);
	CellRangeAddress rangle = new CellRangeAddress(row, row, firstCol, lastCol);
	sheet.addMergedRegion(rangle);
	this.setCellRangeAddressBorder(rangle, sheet);
	return row + 1;
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:16,代碼來源:ExcelReportBuilder.java

示例4: createFirstRow

import org.apache.poi.ss.usermodel.Cell; //導入方法依賴的package包/類
private static List<String> createFirstRow(String sheetName,
        List<Locale> locales, Sheet sheet, CellStyle styleTitle) {
    int colIdx = 0;
    Row titleRow = sheet.createRow(0);
    sheet.setColumnWidth(colIdx, 30 * 256);
    Cell titleCell = titleRow.createCell(colIdx++);
    titleCell.setCellStyle(styleTitle);
    titleCell.setCellValue(getDefaultResourceBundle().getString(
            BaseBean.LABEL_SHOP_TRANSLARIONS_KEY));
    return createColumnHeaders(sheetName, locales, sheet, styleTitle,
            colIdx, titleRow);
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:13,代碼來源:ExcelHandler.java

示例5: formatCellStatus

import org.apache.poi.ss.usermodel.Cell; //導入方法依賴的package包/類
protected void formatCellStatus(Sheet sheet, Cell cell) {
	cell.setCellStyle(styles.get("status"));
	SheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting();
	ConditionalFormattingRule ruleGreen = sheetCF.createConditionalFormattingRule(ComparisonOperator.EQUAL, "1");
	PatternFormatting fill1 = ruleGreen.createPatternFormatting();
	fill1.setFillBackgroundColor(IndexedColors.GREEN.index);
	fill1.setFillPattern(PatternFormatting.SOLID_FOREGROUND);
	//
	ConditionalFormattingRule ruleRed = sheetCF.createConditionalFormattingRule(ComparisonOperator.EQUAL, "0");
	PatternFormatting fill2 = ruleRed.createPatternFormatting();
	fill2.setFillBackgroundColor(IndexedColors.RED.index);
	fill2.setFillPattern(PatternFormatting.SOLID_FOREGROUND);
	//
	ConditionalFormattingRule ruleOrange = sheetCF.createConditionalFormattingRule(ComparisonOperator.EQUAL, "2");
	PatternFormatting fill3 = ruleOrange.createPatternFormatting();
	fill3.setFillBackgroundColor(IndexedColors.ORANGE.index);
	fill3.setFillPattern(PatternFormatting.SOLID_FOREGROUND);
	//
	String name = CellReference.convertNumToColString(cell.getColumnIndex());
	String location = "$" + name + "$" + cell.getRowIndex() + ":$" + name + "$" + (cell.getRowIndex() + 1);

	CellRangeAddress[] regions = { CellRangeAddress.valueOf(location) };
	ConditionalFormattingRule[] cfRules = new ConditionalFormattingRule[] { ruleGreen, ruleRed, ruleOrange };
	sheetCF.addConditionalFormatting(regions, cfRules);
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:26,代碼來源:XLTest.java

示例6: writeTitle

import org.apache.poi.ss.usermodel.Cell; //導入方法依賴的package包/類
/**
 * 向當前Sheet第一行(1-based)寫入標題,若用戶沒有開啟寫入標題總開關(即{@link #isWriteTitle}為false),
 * 或者{@link #titles}為空則不會做任何操作
 */
private void writeTitle() {
    if (!this.isWriteTitle || this.titles == null || this.titles.isEmpty()) {
        return;
    }
    this.currentRowInSheet++;
    Row row = this.currentSheetPO.createRow(this.currentRowInSheet);
    row.setHeight(this.rowHeight < 0 ? -1 : this.rowHeight);
    for (int i = 0; i < this.titles.size(); i++) {
        Cell cell = row.createCell(i);
        cell.setCellStyle(this.defaultTitleCellStyle);
        cell.setCellValue(this.titles.get(i));
    }
    this.realRowInSheet++;
    this.realRowInExcel++;
}
 
開發者ID:FlyingHe,項目名稱:UtilsMaven,代碼行數:20,代碼來源:XLSXWriter.java

示例7: addHeaderRow

import org.apache.poi.ss.usermodel.Cell; //導入方法依賴的package包/類
/**
 * Adds the header row. Override this method to change header-row-related
 * aspects of the workbook. Alternately, the header Row Object is accessible
 * via getHeaderRow() after report creation. To change header CellStyle,
 * though, use setHeaderStyle().
 *
 * @param row the row
 */
protected void addHeaderRow(final int row) {
    headerRow = sheet.createRow(row);
    Cell headerCell;
    headerRow.setHeightInPoints(40);
    int col = 0;
    for (final String propId : getPropIds()) {
        headerCell = headerRow.createCell(col);
        headerCell.setCellValue(createHelper.createRichTextString(getGridHolder().getColumnHeader(propId)));
        headerCell.setCellStyle(getColumnHeaderStyle(row, col));

        final HorizontalAlignment poiAlignment = getGridHolder().getCellAlignment(propId);
        CellUtil.setAlignment(headerCell, poiAlignment);
        col++;
    }
}
 
開發者ID:TFyre,項目名稱:vaadin-gridexport,代碼行數:24,代碼來源:ExcelExport.java

示例8: createSheetDataRow

import org.apache.poi.ss.usermodel.Cell; //導入方法依賴的package包/類
private static <T> void createSheetDataRow(List<T> dataList, int dataRowNum,
		int listStart, int listEnd,ExportInfo exportInfo,
		Map<Field, CellStyle> dataCellStyleMap, List<Field> availableFields,Sheet sheet)
		throws IllegalAccessException, InvocationTargetException {
	
	Map<Field, ExportFieldInfo> fieldInfoMap = exportInfo.getFieldInfoMap();
	Cell cell;
	Field field;
	Row row;
	T obj ;
	int dataSize = dataList.size() ;
	listEnd = listEnd > dataSize ? dataSize : listEnd ;
	int fieldListSize = availableFields.size();
	int dataHightInPoint = exportInfo.getDataHightInPoint();
	for(int i = listStart ; i < listEnd ; i++ , dataRowNum ++){
		obj = dataList.get(i);
		row = sheet.createRow(dataRowNum ); 
		row.setHeightInPoints(dataHightInPoint);
		for(int j = 0 ; j < fieldListSize ; j++){
			field = availableFields.get(j);
			if(field == null ){
				continue;
			}
			cell= row.createCell(j);
			Object returnVal = obj;
			List<Method> methods = fieldInfoMap.get(field).getMethodChain();
			for(Method method : methods){
				if (returnVal == null) {
					continue;
				}
				returnVal = method.invoke(returnVal);
			}
			
			setCellValue(cell, fieldInfoMap.get(field),  returnVal, obj);
			if(dataCellStyleMap != null && dataCellStyleMap.get(field) != null){
				cell.setCellStyle(dataCellStyleMap.get(field));					
			}
		}
	}
}
 
開發者ID:long47964,項目名稱:excel-utils,代碼行數:41,代碼來源:ExcelExportUtil.java

示例9: writeValue

import org.apache.poi.ss.usermodel.Cell; //導入方法依賴的package包/類
/**
 * @param column
 * @param line
 * @param value
 * @param style
 */
private void writeValue(String column, int line, String value, CellStyle style) {
    logger.debug("Writing: [{}] at line [{}] in column [{}]", value, line, column);
    final int colIndex = columns.indexOf(column);
    final Sheet sheet = workbook.getSheetAt(0);
    final Row row = sheet.getRow(line);
    Cell cell = row.getCell(colIndex);
    if (cell != null) {
        row.removeCell(cell);
    }
    cell = row.createCell(colIndex);
    cell.setCellStyle(style);
    cell.setCellValue(value);
    saveOpenExcelFile();
}
 
開發者ID:NoraUi,項目名稱:NoraUi,代碼行數:21,代碼來源:ExcelDataProvider.java

示例10: writeComment

import org.apache.poi.ss.usermodel.Cell; //導入方法依賴的package包/類
/**
 * Adds the given information as a new row to the sheet.
 * @param id: plant ID number
 * @param comment: comment left by visitor
 * @param timestamp: time the user left the comment
 */
public void writeComment(String id, String commonName, String cultivar, String gardenLocation, String comment, Date timestamp){
    Row row = commentsSheet.createRow((short) commentCount);

    Cell cell = row.createCell(0);
    cell.setCellValue(id);

    cell = row.createCell(1);
    cell.setCellValue(commonName);

    cell = row.createCell(2);
    cell.setCellValue(cultivar);

    cell = row.createCell(3);
    cell.setCellValue(gardenLocation);

    cell = row.createCell(4);

    CellStyle style = workbook.createCellStyle();
    style.setWrapText(true);
    cell.setCellStyle(style);
    cell.setCellValue(comment);

    cell = row.createCell(5);
    cell.setCellValue(timestamp.toString());

    commentCount++;
}
 
開發者ID:UMM-CSci-3601-S17,項目名稱:digital-display-garden-iteration-4-dorfner-v2,代碼行數:34,代碼來源:CollectedDataWriter.java

示例11: createColumnHeaders

import org.apache.poi.ss.usermodel.Cell; //導入方法依賴的package包/類
private static List<String> createColumnHeaders(String sheetName,
        List<Locale> locales, Sheet sheet, CellStyle styleTitle,
        int colIdx, Row titleRow) {
    Cell titleCell;
    List<String> localeList = new ArrayList<String>();
    int localesSize = locales.size();
    String cellValue = null;
    for (int i = 0; i < localesSize; i++) {
        sheet.setColumnWidth(colIdx, 40 * 256);
        titleCell = titleRow.createCell(colIdx++);
        titleCell.setCellStyle(styleTitle);
        if (i < 3
                && !BaseBean.LABEL_SHOP_TRANSLARIONS.equals(sheetName)
                && StandardLanguage.isStandardLanguage(locales.get(i)
                        .getLanguage())) {
            cellValue = locales.get(i).getLanguage()
                    + StandardLanguage.COLUMN_HEADING_SUFFIX;
            titleCell.setCellValue(cellValue);
            localeList.add(cellValue);

        } else {
            cellValue = locales.get(i).getLanguage();
            titleCell.setCellValue(cellValue);
            localeList.add(cellValue);
        }
    }
    if (locales.size() == 3
            && !BaseBean.LABEL_SHOP_TRANSLARIONS.equals(sheetName)) {
        sheet.setColumnWidth(colIdx, 40 * 256);
        titleCell = titleRow.createCell(colIdx++);
        titleCell.setCellStyle(styleTitle);
        titleCell.setCellValue(ADDLANGUAGE);
    }

    return localeList;
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:37,代碼來源:ExcelHandler.java

示例12: CreateCellM

import org.apache.poi.ss.usermodel.Cell; //導入方法依賴的package包/類
public static void CreateCellM(Cell c, Row r, Sheet s, CellStyle cs, int colinaI, int colinaF, String valorS, int linhaI, int linhaF) {
    c = r.createCell(linhaI);
    c.setCellStyle(cs);
    c.setCellValue(valorS);
    s.addMergedRegion(new CellRangeAddress(colinaI, colinaF, linhaI, linhaF));
    for (int e = (linhaI + 1); e <= linhaF; e++) {
        c = r.createCell(e);
        c.setCellStyle(cs);
    }
}
 
開發者ID:JIGAsoftSTP,項目名稱:NICON,代碼行數:11,代碼來源:ListaVeiculo.java

示例13: createSummaryColumns

import org.apache.poi.ss.usermodel.Cell; //導入方法依賴的package包/類
private void createSummaryColumns(Sheet sheet) {
	Row headerRow = sheet.createRow(ROW_INDEX_COLUMNS_DESCRIPTIONS);
	headerRow.setHeightInPoints(40);
	Cell headerCell;
	for (int i = 0; i < titlesSummary.length; i++) {
		headerCell = headerRow.createCell(i);
		headerCell.setCellValue(titlesSummary[i]);
		headerCell.setCellStyle(styles.get("header"));
	}
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:11,代碼來源:XLTestSummarySheet.java

示例14: createTitle

import org.apache.poi.ss.usermodel.Cell; //導入方法依賴的package包/類
private void createTitle(Sheet sheet, String xl_sheet_title) {
	Row titleRow = sheet.createRow(ROW_INDEX_TITLE);
	titleRow.setHeightInPoints(45);
	Cell titleCell = titleRow.createCell(0);
	titleCell.setCellValue(xl_sheet_title);
	titleCell.setCellStyle(styles.get("title"));
	sheet.addMergedRegion(CellRangeAddress.valueOf("$A$1:$F$1"));
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:9,代碼來源:XLTestSummarySheet.java

示例15: CreateCell

import org.apache.poi.ss.usermodel.Cell; //導入方法依賴的package包/類
public void CreateCell(Cell c, Row r, Sheet s, CellStyle cs, int colinaI, int colinaF, String valorS, int linhaI, int linhaF) {
  
    c = r.createCell(linhaI);
    c.setCellStyle(cs);
    c.setCellValue(valorS);
    s.addMergedRegion(new CellRangeAddress(colinaI, colinaF, linhaI, linhaF));
    for (int e = (linhaI + 1); e <= linhaF; e++) {
        c = r.createCell(e);
        c.setCellStyle(cs);
    }
}
 
開發者ID:JIGAsoftSTP,項目名稱:NICON,代碼行數:12,代碼來源:ExportMapaProducaoExcel__.java


注:本文中的org.apache.poi.ss.usermodel.Cell.setCellStyle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。