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


Java HSSFRow類代碼示例

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


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

示例1: makeHeader

import org.apache.poi.hssf.usermodel.HSSFRow; //導入依賴的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: readXls

import org.apache.poi.hssf.usermodel.HSSFRow; //導入依賴的package包/類
/**
 * Read the Excel 2003-2007
 * 
 * @param path
 *            the path of the Excel
 * @return
 * @throws IOException
 */
public static String readXls(String path) throws IOException {
	InputStream is = new FileInputStream(path);
	HSSFWorkbook hssfWorkbook = new HSSFWorkbook(is);
	StringBuffer sb = new StringBuffer("");
	// Read the Sheet
	for (int numSheet = 0; numSheet < hssfWorkbook.getNumberOfSheets(); numSheet++) {
		HSSFSheet hssfSheet = hssfWorkbook.getSheetAt(numSheet);
		if (hssfSheet == null) {
			continue;
		}
		// Read the Row
		for (int rowNum = 1; rowNum <= hssfSheet.getLastRowNum(); rowNum++) {
			HSSFRow hssfRow = hssfSheet.getRow(rowNum);
			if (hssfRow != null) {
				HSSFCell no = hssfRow.getCell(0);
				HSSFCell name = hssfRow.getCell(1);
				sb.append(no + ":" + name);
				sb.append(";");
			}
		}
	}
	return sb.toString().substring(0, sb.toString().length() - 1);
}
 
開發者ID:wufeisoft,項目名稱:data,代碼行數:32,代碼來源:ReadExcelUtil.java

示例3: insertItemToSheet

import org.apache.poi.hssf.usermodel.HSSFRow; //導入依賴的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

示例4: writeXLSFile

import org.apache.poi.hssf.usermodel.HSSFRow; //導入依賴的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

示例5: createColumnHeaders

import org.apache.poi.hssf.usermodel.HSSFRow; //導入依賴的package包/類
/**
 */
protected void createColumnHeaders() {
	final HSSFRow headersRow = this.sheet.createRow(0);
	final HSSFFont font = this.workbook.createFont();
	font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
	final HSSFCellStyle style = this.workbook.createCellStyle();
	style.setFont(font);
	style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
	int counter = 1;
	for (int i = 0; i < this.model.getColumnCount(); i++) {
		final HSSFCell cell = headersRow.createCell(counter++);
		// cell.setEncoding(HSSFCell.ENCODING_UTF_16);
		cell.setCellValue(this.model.getColumnName(i));
		cell.setCellStyle(style);
	}
}
 
開發者ID:kiswanij,項目名稱:jk-util,代碼行數:18,代碼來源:JKExcelUtil.java

示例6: createHeader

import org.apache.poi.hssf.usermodel.HSSFRow; //導入依賴的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

示例7: copySheets

import org.apache.poi.hssf.usermodel.HSSFRow; //導入依賴的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

示例8: getIntCellValue

import org.apache.poi.hssf.usermodel.HSSFRow; //導入依賴的package包/類
public static int getIntCellValue(HSSFSheet sheet, int r, int c) {
	HSSFRow row = sheet.getRow(r);
	if (row == null) {
		return 0;
	}
	HSSFCell cell = row.getCell(c);

	try {
		if (cell.getCellType() != HSSFCell.CELL_TYPE_NUMERIC) {
			return 0;
		}
	} catch (RuntimeException e) {
		System.err.println("Exception at sheet name:"
				+ sheet.getSheetName() + ", row:" + (r + 1) + ", col:"
				+ (c + 1));
		throw e;
	}

	return (int) cell.getNumericCellValue();
}
 
開發者ID:kozake,項目名稱:ermaster-k,代碼行數:21,代碼來源:POIUtils.java

示例9: createWorkbook

import org.apache.poi.hssf.usermodel.HSSFRow; //導入依賴的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

示例10: getCellValue

import org.apache.poi.hssf.usermodel.HSSFRow; //導入依賴的package包/類
/**
 * 獲取EXCEL文件單元列值
 * 
 * @param row
 * @param point
 * @return
 */
private static String getCellValue(HSSFRow row, int point) {
	String reString = "";
	try {
		HSSFCell cell = row.getCell((short) point);
		if (cell.getCellType() == 1)
			reString = cell.getStringCellValue();
		else if (cell.getCellType() == 0) {
			reString = convert(cell.getNumericCellValue());
			BigDecimal bd = new BigDecimal(reString);
			reString = bd.toPlainString();
		} else {
			reString = "";
		}
		System.out.println(cell.getCellType() + ":" + cell.getCellFormula());
	} catch (Exception localException) {
	}
	return checkNull(reString);
}
 
開發者ID:fellyvon,項目名稱:wasexport,代碼行數:26,代碼來源:ExcelUtil.java

示例11: getXLS

import org.apache.poi.hssf.usermodel.HSSFRow; //導入依賴的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

示例12: getXLS

import org.apache.poi.hssf.usermodel.HSSFRow; //導入依賴的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

示例13: getXLS

import org.apache.poi.hssf.usermodel.HSSFRow; //導入依賴的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

示例14: reader

import org.apache.poi.hssf.usermodel.HSSFRow; //導入依賴的package包/類
public static void reader(String filePath) {
	try {
		POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(filePath));
		HSSFWorkbook wb = new HSSFWorkbook(fs);
		HSSFSheet sheet = wb.getSheetAt(0);
		HSSFRow row = sheet.getRow(3);
		HSSFCell cell = row.getCell((short) 0);
		int type = cell.getCellType();
		String msg = getCellStringValue(cell);
		System.out.println(type + ":" + msg);
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
開發者ID:wkeyuan,項目名稱:DWSurvey,代碼行數:15,代碼來源:ReadExcelUtil.java

示例15: createRow

import org.apache.poi.hssf.usermodel.HSSFRow; //導入依賴的package包/類
/**
 *
 * @param rowIndex
 *            int
 */
protected void createRow(final int rowIndex) {
	final HSSFRow row = this.sheet.createRow(rowIndex + 1); // since the
															// rows in
	// excel starts from 1
	// not 0
	final HSSFCellStyle style = this.workbook.createCellStyle();
	style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
	int counter = 1;
	for (int i = 0; i < this.model.getColumnCount(); i++) {
		final HSSFCell cell = row.createCell(counter++);
		// cell.setEncoding(HSSFCell.ENCODING_UTF_16);
		final Object value = this.model.getValueAt(rowIndex, i);
		setValue(cell, value);
		cell.setCellStyle(style);
	}
}
 
開發者ID:kiswanij,項目名稱:jk-util,代碼行數:22,代碼來源:JKExcelUtil.java


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