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


Java Sheet.setColumnWidth方法代碼示例

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


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

示例1: buildSheet

import org.apache.poi.ss.usermodel.Sheet; //導入方法依賴的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: autosizeColumns

import org.apache.poi.ss.usermodel.Sheet; //導入方法依賴的package包/類
public static void autosizeColumns(Sheet sheet, int numColumns) {
    for (int i = 0; i < numColumns; i++) {
        sheet.autoSizeColumn(i);
        int cw = (int) (sheet.getColumnWidth(i) * 0.8);
        // increase width to accommodate drop-down arrow in the header
        sheet.setColumnWidth(i, Math.max(Math.min(cw, MAX_COL_WIDTH), MIN_COL_WIDTH));
    }
}
 
開發者ID:Adobe-Consulting-Services,項目名稱:aem-epic-tool,代碼行數:9,代碼來源:ReportUtil.java

示例3: createFirstRow

import org.apache.poi.ss.usermodel.Sheet; //導入方法依賴的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

示例4: setColumWidth

import org.apache.poi.ss.usermodel.Sheet; //導入方法依賴的package包/類
private static void setColumWidth(ExcelFileType type,ExportInfo exportInfo,
		List<Field> availableFields,Sheet sheet) {
	Map<Field, ExportFieldInfo> fieldInfoMap = exportInfo.getFieldInfoMap();
	for(int i = 0 ; i < availableFields.size() ; i++){
		Field field = availableFields.get(i);
		ExportFieldInfo excelFieldInfo = fieldInfoMap.get(field);
		if (excelFieldInfo.getWidth() != null) {
			sheet.setColumnWidth(i, excelFieldInfo.getWidth()*256);	
			continue;
		}
		if(excelFieldInfo.getAutoWidth() != null){
			if(ExcelFileType.XLS == type){
				HSSFSheet hSheet = (HSSFSheet) sheet;
				hSheet.autoSizeColumn(i);
			}else if(ExcelFileType.XLSX == type){
				XSSFSheet xSheet = (XSSFSheet) sheet;
				xSheet.autoSizeColumn(i);
			}
		}
	}
}
 
開發者ID:long47964,項目名稱:excel-utils,代碼行數:22,代碼來源:ExcelExportUtil.java

示例5: sizeColumns

import org.apache.poi.ss.usermodel.Sheet; //導入方法依賴的package包/類
/**
 * Does the sizing of the colums, for a first draft the auto size mechanism of excel is used.
 * 
 * @param sheet the sheet where the columns should be sized
 * @param langs the languages to calculate the columns to be sized.
 */
private void sizeColumns(	Sheet sheet,
							Map<Locale, Integer> langs)
{
	LOG.info("Size columns of sheet " + sheet.getSheetName());
	sheet.autoSizeColumn(this.keyColumn, true);
	for (Integer lang : langs.values())
	{
		sheet.setColumnWidth(lang, this.columnWidth);
	}
}
 
開發者ID:namics,項目名稱:spring-i18n-support,代碼行數:17,代碼來源:ExcelWriter.java

示例6: createColumnHeaders

import org.apache.poi.ss.usermodel.Sheet; //導入方法依賴的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

示例7: createCell

import org.apache.poi.ss.usermodel.Sheet; //導入方法依賴的package包/類
public static 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.setColumnWidth(linhaI, linhaF*1000);
    }
 
開發者ID:JIGAsoftSTP,項目名稱:NICON,代碼行數:8,代碼來源:GenericExcel.java

示例8: CreateCell

import org.apache.poi.ss.usermodel.Sheet; //導入方法依賴的package包/類
public static void CreateCell(Cell c, Row r, Sheet s, CellStyle cs, int colinaI, int colinaF, Object valorS, int linhaI, int linhaF) {
    c = r.createCell(linhaI);
    c.setCellStyle(cs);
    if(valorS instanceof Integer) c.setCellValue((Integer)valorS);
    else c.setCellValue((String)valorS);
    s.setColumnWidth(linhaI, linhaF*500);
}
 
開發者ID:JIGAsoftSTP,項目名稱:NICON,代碼行數:8,代碼來源:ListaVeiculo.java

示例9: buildGridExcelData

import org.apache.poi.ss.usermodel.Sheet; //導入方法依賴的package包/類
private int buildGridExcelData(ReportGrid gridModel, Sheet sheet, int starDataRow, Map<String, CellStyle> styles) {
	CellStyle dataAlignLeftStyle = styles.get(GridStyleType.dataAlignLeftStyle.name());
	CellStyle dataAlignCenterStyle = styles.get(GridStyleType.dataAlignCenterStyle.name());
	CellStyle dataAlignRightStyle = styles.get(GridStyleType.dataAlignRightStyle.name());
	
	IFillCellInterceptor interceptor = ContextHolder.getBean(IFillCellInterceptor.BEAN_ID);
	List<ReportGridHeader> bottomGridExcelHeader = new ArrayList<ReportGridHeader>();
	this.calculateBottomColumnHeader(gridModel.getGridHeaderModelList(), bottomGridExcelHeader);
	
	List<Map<String, Object>> excelDatas = gridModel.getGridDataModel().getDatas();
	String treeColumn = gridModel.getGridDataModel().getTreeColumn();
	int excelDataIndex = 0;
	int rowSize = excelDatas.size();
	Cell cell;
	Row row;
	for (int rowNum = starDataRow; rowNum <= starDataRow + rowSize - 1; rowNum++) {
		row = sheet.createRow(rowNum);
		Map<String, Object> map = excelDatas.get(excelDataIndex);
		int j = 0;
		for (ReportGridHeader header : bottomGridExcelHeader) {
			Object value = map.get(header.getColumnName());
			int dataAlign = header.getDataAlign();
			cell = row.createCell(j);
			if (dataAlign == 1) {
				cell.setCellStyle(dataAlignCenterStyle);
			} else if (dataAlign == 2) {
				cell.setCellStyle(dataAlignRightStyle);
			} else {
				cell.setCellStyle(dataAlignLeftStyle);
			}
			if (value != null) {
				if (header.getColumnName().equalsIgnoreCase(treeColumn)) {
					int level = this.calculateIndentationCount(value.toString());
					cell.setCellStyle(new GridStyleBuilder().createIndentationCellStyle(sheet.getWorkbook(), level == 0 ? 0 : level * 2));
					cell.setCellValue(value.toString());
				} else {
					if (value instanceof BigDecimal || value instanceof Float || value instanceof Double){
				         CellStyle style = cell.getCellStyle();  
						 DataFormat format = sheet.getWorkbook().createDataFormat();  
						 String displayFormat = header.getDisplayFormat();
						 if (StringUtils.isEmpty(displayFormat))
							 style.setDataFormat(format.getFormat("#,##0.00")); 
						 else
							 style.setDataFormat(format.getFormat(displayFormat));
						 cell.setCellStyle(style);
					}
					interceptor.fillCellValue(sheet, row, cell, value);
				}

			} else {
				cell.setCellValue("");
			}
			sheet.setColumnWidth(cell.getColumnIndex(), header.getWidth() / 6 > 255 ? 254 * 256 : header.getWidth() / 6 * 256);
			j++;
		}
		excelDataIndex++;
	}
	return starDataRow + rowSize;

}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:61,代碼來源:ExcelReportBuilder.java


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