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


Java HSSFSheet.createRow方法代碼示例

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


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

示例1: makeHeader

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的package包/類
private void makeHeader ( final List<Field> columns, final HSSFSheet sheet )
{
    final Font font = sheet.getWorkbook ().createFont ();
    font.setFontName ( "Arial" );
    font.setBoldweight ( Font.BOLDWEIGHT_BOLD );
    font.setColor ( HSSFColor.WHITE.index );

    final CellStyle style = sheet.getWorkbook ().createCellStyle ();
    style.setFont ( font );
    style.setFillForegroundColor ( HSSFColor.BLACK.index );
    style.setFillPattern ( PatternFormatting.SOLID_FOREGROUND );

    final HSSFRow row = sheet.createRow ( 0 );

    for ( int i = 0; i < columns.size (); i++ )
    {
        final Field field = columns.get ( i );

        final HSSFCell cell = row.createCell ( i );
        cell.setCellValue ( field.getHeader () );
        cell.setCellStyle ( style );
    }
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:24,代碼來源:ExportEventsImpl.java

示例2: insertItemToSheet

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的package包/類
private void insertItemToSheet(String table, HSSFSheet sheet, ArrayList<String> columns) {
    HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
    Cursor cursor = database.rawQuery("select * from " + table, null);
    cursor.moveToFirst();
    int n = 1;
    while (!cursor.isAfterLast()) {
        HSSFRow rowA = sheet.createRow(n);
        for (int j = 0; j < columns.size(); j++) {
            HSSFCell cellA = rowA.createCell(j);
            if (cursor.getType(j) == Cursor.FIELD_TYPE_BLOB) {
                HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 0, (short) j, n, (short) (j + 1), n + 1);
                anchor.setAnchorType(3);
                patriarch.createPicture(anchor, workbook.addPicture(cursor.getBlob(j), HSSFWorkbook.PICTURE_TYPE_JPEG));
            } else {
                cellA.setCellValue(new HSSFRichTextString(cursor.getString(j)));
            }
        }
        n++;
        cursor.moveToNext();
    }
    cursor.close();
}
 
開發者ID:androidmads,項目名稱:SQLite2XL,代碼行數:23,代碼來源:SQLiteToExcel.java

示例3: writeXLSFile

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的package包/類
public static void writeXLSFile() throws IOException {

			HSSFWorkbook wbObj = new HSSFWorkbook();
			HSSFSheet sheet = wbObj.createSheet(sheetName);

			for (int row = 0; row < tableData.size(); row++) {
				HSSFRow rowObj = sheet.createRow(row);
				rowData = tableData.get(row);
				for (int col = 0; col < rowData.size(); col++) {
					HSSFCell cellObj = rowObj.createCell(col);
					cellObj.setCellValue(rowData.get(col));
				}
			}

			FileOutputStream fileOut = new FileOutputStream(excelFileName);
			wbObj.write(fileOut);
			wbObj.close();
			fileOut.flush();
			fileOut.close();
		}
 
開發者ID:sergueik,項目名稱:SWET,代碼行數:21,代碼來源:TableEditorEx.java

示例4: createHeader

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的package包/類
private void createHeader(HSSFSheet sheet, List<ExpedientConsultaDissenyDto> expedientsConsultaDissenyDto) {
	int rowNum = 0;
	int colNum = 0;

	// Capçalera
	HSSFRow xlsRow = sheet.createRow(rowNum++);

	HSSFCell cell;
	
	cell = xlsRow.createCell(colNum++);
	cell.setCellValue(new HSSFRichTextString(StringUtils.capitalize("Expedient")));
	cell.setCellStyle(headerStyle);
	
	Iterator<Entry<String, DadaIndexadaDto>> it = expedientsConsultaDissenyDto.get(0).getDadesExpedient().entrySet().iterator();
	while (it.hasNext()) {
		Map.Entry<String, DadaIndexadaDto> e = (Map.Entry<String, DadaIndexadaDto>)it.next();
		sheet.autoSizeColumn(colNum);
		cell = xlsRow.createCell(colNum++);
		cell.setCellValue(new HSSFRichTextString(StringUtils.capitalize(e.getValue().getEtiqueta())));
		cell.setCellStyle(headerStyle);
	}
}
 
開發者ID:GovernIB,項目名稱:helium,代碼行數:23,代碼來源:ExpedientInformeController.java

示例5: copySheets

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的package包/類
/**
 * @param newSheet the sheet to create from the copy.
 * @param sheet the sheet to copy.
 * @param copyStyle true copy the style.
 */
public static void copySheets(HSSFSheet newSheet, HSSFSheet sheet, boolean copyStyle) {
    int maxColumnNum = 0;
    Map<Integer, HSSFCellStyle> styleMap = (copyStyle) ? new HashMap<Integer, HSSFCellStyle>() : null;
    for (int i = sheet.getFirstRowNum(); i <= sheet.getLastRowNum(); i++) {
        HSSFRow srcRow = sheet.getRow(i);
        HSSFRow destRow = newSheet.createRow(i);
        if (srcRow != null) {
            Util.copyRow(sheet, newSheet, srcRow, destRow, styleMap);
            if (srcRow.getLastCellNum() > maxColumnNum) {
                maxColumnNum = srcRow.getLastCellNum();
            }
        }
    }
    for (int i = 0; i <= maxColumnNum; i++) {
        newSheet.setColumnWidth(i, sheet.getColumnWidth(i));
    }
   //Util.copyPictures(newSheet,sheet) ;
}
 
開發者ID:likelet,項目名稱:DAtools,代碼行數:24,代碼來源:Util.java

示例6: createWorkbook

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的package包/類
private HSSFWorkbook createWorkbook() {
    HSSFWorkbook workbook = new HSSFWorkbook();
    HSSFSheet sheet = workbook.createSheet();

    // Add dummy lines
    sheet.createRow(0).createCell(0).setCellValue("First dummy row");
    sheet.createRow(1).createCell(0).setCellValue("Second dummy row");

    HSSFRow row = sheet.createRow(2);
    row.createCell(13).setCellValue("BoundaryPoint FR-BE");
    row.createCell(14).setCellValue("France");
    row.createCell(15).setCellValue("Belgium");

    return workbook;
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:16,代碼來源:BoundaryPointXlsParserTest.java

示例7: getXLS

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的package包/類
/**
 * Creates XLS document from given list of {@link PollOption} objects.
 * 
 * @param results List of {@link PollOption} objects.
 * @return XLS document.
 */
public static HSSFWorkbook getXLS(List<PollOption> results) {
    HSSFWorkbook document = new HSSFWorkbook();
    HSSFSheet sheet = document.createSheet("Results");
    HSSFRow rowhead = sheet.createRow(0);
    rowhead.createCell(0).setCellValue("Ime opcije:");
    rowhead.createCell(1).setCellValue("Broj glasova:");

    for (int i = 0; i < results.size(); i++) {
        HSSFRow row = sheet.createRow(i + 1);
        row.createCell(0).setCellValue(results.get(i).getName());
        row.createCell(1).setCellValue(
                Double.valueOf(results.get(i).getVotes()));
    }
    return document;
}
 
開發者ID:fgulan,項目名稱:java-course,代碼行數:22,代碼來源:DBUtility.java

示例8: getXLS

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的package包/類
/**
 * Creates XLS document based on given input parameters.
 * 
 * @param a Start number.
 * @param b End number.
 * @param n Last power.
 * @return Created XLS document.
 */
private HSSFWorkbook getXLS(Integer a, Integer b, Integer n) {
    HSSFWorkbook workbook = new HSSFWorkbook();

    for (int i = 1; i <= n; i++) {
        HSSFSheet sheet = workbook.createSheet(i + "-th power.");
        HSSFRow rowHead = sheet.createRow(0);
        rowHead.createCell(0).setCellValue("x");
        rowHead.createCell(1).setCellValue("x^" + i);

        int rowCounter = 1;
        for (int j = a; j <= b; j++) {
            HSSFRow row = sheet.createRow(rowCounter++);
            row.createCell(0).setCellValue(Double.valueOf(j));
            row.createCell(1).setCellValue(Math.pow(Double.valueOf(j), i));
        }
    }
    return workbook;
}
 
開發者ID:fgulan,項目名稱:java-course,代碼行數:27,代碼來源:PowersServlet.java

示例9: getXLS

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的package包/類
/**
 * Creates XLS document based from given list of bands.
 * 
 * @param results List of bands.
 * @return XLS document.
 */
public static HSSFWorkbook getXLS(List<Band> results) {
    HSSFWorkbook workbook = new HSSFWorkbook();
    HSSFSheet sheet = workbook.createSheet("Voting results");
    HSSFRow rowHead = sheet.createRow(0);
    rowHead.createCell(0).setCellValue("Band name:");
    rowHead.createCell(1).setCellValue("Number of votes:");

    for (int i = 0, size = results.size(); i < size; i++) {
        HSSFRow row = sheet.createRow(i + 1);
        row.createCell(0).setCellValue(results.get(i).getName());
        row.createCell(1).setCellValue(
                Double.valueOf(results.get(i).getVotes()));
    }
    return workbook;
}
 
開發者ID:fgulan,項目名稱:java-course,代碼行數:22,代碼來源:ServerUtilty.java

示例10: writeBody

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的package包/類
void writeBody(HSSFSheet sheet){
		Set<String> keySet = getColumnJson().keySet();
		List<T> ts = getData();
		for (T t:ts) {
//			Class cls = t.getClass();
			int cellNumber = 0;//將cellNumber從0開始
			HSSFRow row = sheet.createRow(addRowNumber());//創建新的一行
			for(String key:keySet){
				try {
					HSSFCell cell = row.createCell(cellNumber++);
					Object value = getValueByKey(t, key);
					setCellValue(cell, value);
					pubMaxValue(key, value);
				} catch (Exception e) {
					throw new RuntimeException("writeBody", e);
				}
			}
		}
	}
 
開發者ID:leiyong0326,項目名稱:phone,代碼行數:20,代碼來源:ExcelExportSuper.java

示例11: createHeader

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的package包/類
public static boolean createHeader(HSSFWorkbook workbook, HSSFSheet sheet,String[] header) throws Exception{
	boolean flag = false;
	try {
		HSSFCellStyle cellStyle = workbook.createCellStyle();
		cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
	 	cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);

		HSSFRow head_row = sheet.createRow(0); // 創建行
		// 操作head
		for (short h = 0; h < header.length; h++) {
			createcsv(head_row, h, header[h], cellStyle);
		}
		flag = true;
	} catch (Exception e) {
		logger.error(sheet.getSheetName() + " : 抬頭標題創建失敗");
		throw e;
	}
	return flag;
}
 
開發者ID:wufeisoft,項目名稱:ryf_mms2,代碼行數:20,代碼來源:CreateExcelUtil.java

示例12: createContent

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的package包/類
public void createContent(WebInput wi, DocInfo di)throws ControllerException {
	HSSFWorkbook wb = di.getExcelDocument();
	// 創建HSSFSheet對象
	HSSFSheet sheet = wb.createSheet("sheet0");
	// 創建HSSFRow對象
	HSSFRow row = sheet.createRow((short) 0);
	// 創建HSSFCell對象
	HSSFCell cell = row.createCell((short) 0);
	// 用來處理中文問題
	// cell.setEncoding(HSSFCell.ENCODING_UTF_16);
	// 設置單元格的值
	// cell.setCellValue("Hello World! 你好,中文世界");
	String info = wi.getParameter("info");
	HSSFRichTextString rts = new HSSFRichTextString(info);
	cell.setCellValue(rts);
	HSSFCell cell2 = row.createCell((short) 1);
	cell2.setCellValue(new HSSFRichTextString(
			"Beetle Web Framework 頁麵生成Excel文件演示!"));
}
 
開發者ID:jbeetle,項目名稱:BJAF3.x,代碼行數:20,代碼來源:GenExcelController.java

示例13: buildExcelDocument

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的package包/類
@Override
protected void buildExcelDocument(Map<String, Object> model,
		HSSFWorkbook workbook, HttpServletRequest request, HttpServletResponse response)
		throws Exception {
	// get data model which is passed by the Spring container
	List<RatingCountBean> listOfRating = (List<RatingCountBean>) model.get("listOfRatingCount");
	
	// create a new Excel sheet
	HSSFSheet sheet = workbook.createSheet("Feedback Report");
	sheet.setDefaultColumnWidth(30);
	
	// create style for header cells
	CellStyle style = workbook.createCellStyle();
	Font font = workbook.createFont();
	font.setFontName("Arial");
	style.setFillForegroundColor(HSSFColor.BLUE.index);
	style.setFillPattern(CellStyle.SOLID_FOREGROUND);
	font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
	font.setColor(HSSFColor.WHITE.index);
	style.setFont(font);
	
	// create header row
	HSSFRow header = sheet.createRow(0);
	
               
               header.createCell(0).setCellValue("Question Number");
	header.getCell(0).setCellStyle(style);
               
	header.createCell(1).setCellValue("Question");
	header.getCell(1).setCellStyle(style);
	
	header.createCell(2).setCellValue("Very Poor");
	header.getCell(2).setCellStyle(style);
	
	header.createCell(3).setCellValue("Poor");
	header.getCell(3).setCellStyle(style);
	
	header.createCell(4).setCellValue("Good");
	header.getCell(4).setCellStyle(style);
	
	header.createCell(5).setCellValue("Best");
	header.getCell(5).setCellStyle(style);
               
               header.createCell(6).setCellValue("Excellent");
	header.getCell(6).setCellStyle(style);
	
	// create data rows
	int rowCount = 1;
	
	for (RatingCountBean rating : listOfRating) {
		HSSFRow aRow = sheet.createRow(rowCount++);
		aRow.createCell(0).setCellValue(rating.getQuestionId());
		aRow.createCell(1).setCellValue(rating.getQuestionText());
		aRow.createCell(2).setCellValue(rating.getRating_one_total_count());
		aRow.createCell(3).setCellValue(rating.getRating_two_total_count());
		aRow.createCell(4).setCellValue(rating.getRating_three_total_count());
                       aRow.createCell(5).setCellValue(rating.getRating_four_total_count());
                       aRow.createCell(6).setCellValue(rating.getRating_five_total_count());
	}
}
 
開發者ID:mustafamym,項目名稱:FeedbackCollectionAndMgmtSystem,代碼行數:61,代碼來源:ExcelBuilder.java

示例14: setData

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的package包/類
/**
 * 設置單元格數據
 *
 * @param sheet
 * @param rowIndex
 * @param data
 */
private static void setData(HSSFSheet sheet, int rowIndex, String... data) {
    setRegionBorder(sheet, rowIndex, 3, 8);
    HSSFRow row = sheet.getRow(rowIndex) == null ? sheet.createRow(rowIndex) : sheet.getRow(rowIndex);
    getCell(row, 0, -1, data.length > 0 ? data[0] : "");
    getCell(row, 1, -1, data.length > 1 ? data[1] : "");
    getCell(row, 2, -1, data.length > 2 ? data[2] : "");
    getCell(row, 3, -1, data.length > 3 ? data[3] : "");
    getCell(row, 9, -1, data.length > 4 ? data[4] : "");
}
 
開發者ID:ajtdnyy,項目名稱:PackagePlugin,代碼行數:17,代碼來源:FileUtil.java

示例15: test_001

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的package包/類
@Test
public void test_001()
{
    HSSFWorkbook v_Workbook = new HSSFWorkbook();
    HSSFSheet    v_Sheet    = v_Workbook.createSheet("測試單元格顏色");
    
    v_Sheet.setColumnWidth(0 ,2560);
    
    for (int v_RowIndex=0; v_RowIndex<4000; v_RowIndex++)
    {
        HSSFRow v_Row = v_Sheet.createRow(v_RowIndex);
        
        for (int v_ColIndex=0; v_ColIndex<1; v_ColIndex++)
        {
            HSSFCell      v_Cell = v_Row.createCell(v_ColIndex);
            HSSFCellStyle v_CellStyle = v_Workbook.createCellStyle();
            
            v_CellStyle.setFillForegroundColor((short)(v_RowIndex + 1));
            v_CellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
            
            v_Cell.setCellStyle(v_CellStyle);
            v_Cell.setCellValue("" + (v_RowIndex + 1));
        }
    }
    
    ExcelHelp.save(v_Workbook ,"/Users/hy/Downloads/測試2003版本的單元格顏色");
}
 
開發者ID:HY-ZhengWei,項目名稱:hy.common.report,代碼行數:28,代碼來源:JU_Excel2003Color.java


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