当前位置: 首页>>代码示例>>Java>>正文


Java HSSFWorkbook.createSheet方法代码示例

本文整理汇总了Java中org.apache.poi.hssf.usermodel.HSSFWorkbook.createSheet方法的典型用法代码示例。如果您正苦于以下问题:Java HSSFWorkbook.createSheet方法的具体用法?Java HSSFWorkbook.createSheet怎么用?Java HSSFWorkbook.createSheet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.poi.hssf.usermodel.HSSFWorkbook的用法示例。


在下文中一共展示了HSSFWorkbook.createSheet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeXLSFile

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的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

示例2: createWorkbook

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的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

示例3: getXLS

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的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

示例4: getXLS

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的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

示例5: getXLS

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的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

示例6: createSheet

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的package包/类
private Sheet createSheet(HSSFWorkbook wb,Paper paper,String name){
	Sheet sheet = null;
	if(name==null){
		sheet=wb.createSheet();
	}else{			
		sheet=wb.createSheet(name);
	}
	PaperType paperType=paper.getPaperType();
	HSSFPrintSetup printSetup=(HSSFPrintSetup)sheet.getPrintSetup();
	Orientation orientation=paper.getOrientation();
	if(orientation.equals(Orientation.landscape)){
		printSetup.setLandscape(true);
	}
	setupPaper(paperType, printSetup);
	int leftMargin=paper.getLeftMargin();
	int rightMargin=paper.getRightMargin();
	int topMargin=paper.getTopMargin();
	int bottomMargin=paper.getBottomMargin();
	sheet.setMargin(Sheet.LeftMargin, UnitUtils.pointToInche(leftMargin));
	sheet.setMargin(Sheet.RightMargin, UnitUtils.pointToInche(rightMargin));
	sheet.setMargin(Sheet.TopMargin, UnitUtils.pointToInche(topMargin));
	sheet.setMargin(Sheet.BottomMargin, UnitUtils.pointToInche(bottomMargin));
	return sheet;
}
 
开发者ID:youseries,项目名称:ureport,代码行数:25,代码来源:Excel97Producer.java

示例7: exportTables

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的package包/类
private void exportTables(List<String> tables, final String fileName) throws Exception {
    workbook = new HSSFWorkbook();
    for (int i = 0; i < tables.size(); i++) {
        if (!tables.get(i).equals("android_metadata")) {
            HSSFSheet sheet = workbook.createSheet(tables.get(i));
            createSheet(tables.get(i), sheet);
        }
    }
    File file = new File(mExportPath, fileName);
    FileOutputStream fos = new FileOutputStream(file);
    workbook.write(fos);
    fos.flush();
    fos.close();
    workbook.close();
    database.close();
}
 
开发者ID:androidmads,项目名称:SQLite2XL,代码行数:17,代码来源:SQLiteToExcel.java

示例8: beforeClass

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() {

	workbook = new HSSFWorkbook();
	sheet = workbook.createSheet("Default");
	Row row = sheet.createRow(ypos++);

	CellStyle style = workbook.createCellStyle();
	style.setWrapText(true);

	setCell(style, row, 1, "Bytes\nSize");
	setCell(style, row, 2, "Serialization\nRaw");
	setCell(style, row, 3, "Externalizor\nRaw");
	setCell(style, row, 4, "Serialization\nCompressed");
	setCell(style, row, 5, "Externalizor\nCompressed");

	setCell(style, row, 7, "Rate\nrw / sec");
	setCell(style, row, 8, "Serialization\nRaw");
	setCell(style, row, 9, "Externalizor\nRaw");
	setCell(style, row, 10, "Serialization\nCompressed");
	setCell(style, row, 11, "Externalizor\nCompressed");
}
 
开发者ID:qwazr,项目名称:externalizor,代码行数:23,代码来源:BenchmarkTest.java

示例9: export

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的package包/类
private Workbook export() throws IntrospectionException, IllegalArgumentException, IllegalAccessException, InvocationTargetException
{
	first 	= 0;
	pageSize= 10;
	workbook = new HSSFWorkbook(); //XSSFWorkbook(); //HSSFWorkbook();
	Sheet sheet = workbook.createSheet( "export" );
	List<T> list = loadNext();
	int nrow = 1; // 2 righe sono lasciate per l'header
	if ( list != null && !list.isEmpty() )
	{
		while ( list != null && !list.isEmpty() )
		{
			for ( T obj : list )
			{
				nrow++;
				Row row = sheet.createRow( nrow );
				exported.clear();
				export( row, 0, obj );
			}
			list = loadNext();
		}
		exportHeaders( sheet );
	}
	return workbook;
}
 
开发者ID:Inspiredsoft,项目名称:parco,代码行数:26,代码来源:ExportableModelEntityQuery.java

示例10: write

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的package包/类
public void write(String src) throws IOException{
  
  System.out.println(src);
  HSSFWorkbook wb = new HSSFWorkbook();
  HSSFSheet sheet = wb.createSheet("Resultats");
  
  for (int i=0; i<size(); i++) {
    HSSFRow row = sheet.createRow(i);
    HSSFCell cell = row.createCell(0);
    cell.setCellValue(get(i).area());
  }
  
  
  FileOutputStream fileOut;
    fileOut = new FileOutputStream(src);
    wb.write(fileOut);
    fileOut.close();
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:19,代码来源:VectPolygon.java

示例11: dataToWorkbook

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的package包/类
/**
 * 将数据写入workbook
 * @param workbook 不传递则创建一个workbook
 * @param sheetName 为null则默认为"自动导出"
 * @return
 */
public HSSFWorkbook dataToWorkbook(HSSFWorkbook workbook, String sheetName) {
	if (init()) {
		HSSFWorkbook wbook = workbook == null ? new HSSFWorkbook() : workbook;
		// 创建一个sheet
		sheetName = (sheetName == null ? "自动导出" : sheetName);
		HSSFSheet sheet = wbook.createSheet(sheetName);
		//写入表头条件
		writeCondtions(sheet);
		// 写入标题
		writeHead(sheet);
		// 写入内容
		writeBody(sheet);
		autoSheetWidth(sheet);
		completeAfter(sheet);
		return wbook;
	}
	return null;
}
 
开发者ID:leiyong0326,项目名称:phone,代码行数:25,代码来源:ExcelExportSuper.java

示例12: buildExcelDocument

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的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

示例13: createSheet

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的package包/类
private HSSFSheet createSheet ( final List<Event> events, final HSSFWorkbook workbook, final List<Field> columns )
{
    final HSSFSheet sheet = workbook.createSheet ( Messages.ExportImpl_ExcelSheet_Name );

    final HSSFHeader header = sheet.getHeader ();
    header.setLeft ( Messages.ExportImpl_ExcelSheet_Header );
    header.setRight ( HeaderFooter.date () + " " + HeaderFooter.time () );//$NON-NLS-1$

    final HSSFFooter footer = sheet.getFooter ();
    footer.setLeft ( String.format ( Messages.ExportImpl_ExcelSheet_Footer_1, events.size () ) );

    footer.setRight ( Messages.ExportImpl_ExcelSheet_Footer_2 + HeaderFooter.page () + Messages.ExportImpl_ExcelSheet_Footer_3 + HeaderFooter.numPages () );

    makeHeader ( columns, sheet );

    final HSSFPrintSetup printSetup = sheet.getPrintSetup ();
    printSetup.setLandscape ( true );
    printSetup.setFitWidth ( (short)1 );
    printSetup.setFitHeight ( (short)0 );
    printSetup.setPaperSize ( PrintSetup.A4_PAPERSIZE );

    sheet.setAutoFilter ( new CellRangeAddress ( 0, 0, 0, columns.size () - 1 ) );
    sheet.createFreezePane ( 0, 1 );
    sheet.setFitToPage ( true );
    sheet.setAutobreaks ( true );

    printSetup.setFooterMargin ( 0.25 );

    sheet.setMargin ( Sheet.LeftMargin, 0.25 );
    sheet.setMargin ( Sheet.RightMargin, 0.25 );
    sheet.setMargin ( Sheet.TopMargin, 0.25 );
    sheet.setMargin ( Sheet.BottomMargin, 0.5 );

    return sheet;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:36,代码来源:ExportEventsImpl.java

示例14: test_001

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的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

示例15: create

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的package包/类
public List<Sheet> create(String... sheetName) {
    wb = new HSSFWorkbook();
    List<Sheet> listSheet = new ArrayList<Sheet>();
    for (String name : sheetName) {
        @SuppressWarnings("unused")
        Sheet sheet = wb.createSheet(name);
        listSheet.add(sheet);
    }
    save();
    return listSheet;
}
 
开发者ID:BetaSummer,项目名称:sztw,代码行数:12,代码来源:HSSF.java


注:本文中的org.apache.poi.hssf.usermodel.HSSFWorkbook.createSheet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。