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


Java HSSFWorkbook.close方法代码示例

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


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

示例1: doGet

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

    List<PollOption> results = null;
    try {
        Long pollId = (Long) req.getSession().getAttribute("pollID");
        results = DAOProvider.getDao().getPollOptions(pollId);
    } catch (Exception ex) {
        results = new ArrayList<>();
    }

    HSSFWorkbook workbook = DBUtility.getXLS(results);
    resp.setContentType("application/vnd.ms-excel");
    resp.setHeader("Content-Disposition",
            "attachment; filename=votingResults.xls");
    workbook.write(resp.getOutputStream());
    workbook.close();
}
 
开发者ID:fgulan,项目名称:java-course,代码行数:23,代码来源:GlasanjeXLSServlet.java

示例2: 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

示例3: doGet

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

    String definitionFile = req.getServletContext().getRealPath(
            "/WEB-INF/glasanje-definicija.txt");
    String resultFile = req.getServletContext().getRealPath(
            "/WEB-INF/glasanje-rezultati.txt");

    List<Band> results = ServerUtilty
            .getResults(definitionFile, resultFile);

    HSSFWorkbook workbook = ServerUtilty.getXLS(results);
    resp.setContentType("application/vnd.ms-excel");
    resp.setHeader("Content-Disposition",
            "attachment; filename=votingResults.xls");
    workbook.write(resp.getOutputStream());
    workbook.close();
}
 
开发者ID:fgulan,项目名称:java-course,代码行数:23,代码来源:GlasanjeXLSServlet.java

示例4: 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

示例5: readExcel

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的package包/类
public static void readExcel(String filePth) throws Exception {
	InputStream is = new FileInputStream(filePth);
	//创建工作薄
	//XSSFWorkbook hwb = new XSSFWorkbook(is);
	HSSFWorkbook hwb = new HSSFWorkbook(new POIFSFileSystem(is));
	//得到sheet
	for (int i = 0; i < hwb.getNumberOfSheets(); i++) {
		HSSFSheet sheet = hwb.getSheetAt(i);
		int rows = sheet.getPhysicalNumberOfRows();
		//遍历每一行
		for (int j = 0; j < rows; j++) {
			HSSFRow hr = sheet.getRow(j);
			Iterator<?> it = hr.iterator();
			while(it.hasNext()){
				String context = it.next().toString();
				System.out.println(context);
			}
		}
	}
	hwb.close();
}
 
开发者ID:tank2140896,项目名称:JavaWeb,代码行数:22,代码来源:FileUtil.java

示例6: doGet

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    Integer a = null;
    Integer b = null;
    Integer n = null;

    try {
        a = Integer.valueOf(req.getParameter("a"));
        b = Integer.valueOf(req.getParameter("b"));
        n = Integer.valueOf(req.getParameter("n"));
    } catch (Exception ex) {
        req.getRequestDispatcher("/WEB-INF/pages/error.jsp").forward(req,
                resp);
        return;
    }

    if (!isValid(a) || !isValid(b) || n < 1 || n > 5) {
        req.getRequestDispatcher("/WEB-INF/pages/error.jsp").forward(req,
                resp);
        return;
    }

    HSSFWorkbook workbook = getXLS(a, b, n);
    resp.setContentType("application/vnd.ms-excel");
    resp.setHeader("Content-Disposition", "attachment; filename=powers.xls");
    workbook.write(resp.getOutputStream());
    workbook.close();
}
 
开发者ID:fgulan,项目名称:java-course,代码行数:33,代码来源:PowersServlet.java

示例7: getMsgListFromExcel

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的package包/类
@Override
public ArrayList<MsgEntity> getMsgListFromExcel(File targetFile) throws IOException {
	ArrayList<MsgEntity> list = new ArrayList<MsgEntity>();
	POIFSFileSystem fs = new POIFSFileSystem(targetFile);
	HSSFWorkbook workBook = new HSSFWorkbook(fs);
	try {
		System.out.println("开始解析");
		HSSFSheet sheet = workBook.getSheetAt(0);
		int rows = sheet.getLastRowNum() + 1;
		for (int r = 1; r < rows; r++) {
			HSSFRow row = sheet.getRow(r);
			if (row == null) {
				continue;
			}
			MsgEntity msg = new MsgEntity();
			String number = getStringVal(row.getCell(0));
			if(StringUtils.isEmpty(number)){
				continue;
			}
			msg.setTelNumber(number);
			
			String templateId = getStringVal(row.getCell(1));
			if (!StringUtils.isEmpty(templateId) && StringUtils.isNumeric(templateId)
					&& templateId.indexOf(".") == -1) {
				msg.setTemplateId(Long.parseLong(templateId));
			}
			msg.setContent(getStringVal(row.getCell(2)));
			if (HSSFDateUtil.isCellDateFormatted(row.getCell(3))) {
				msg.setSendTime(row.getCell(3).getDateCellValue());
			}
			list.add(msg);
		}
		
	} finally {
		workBook.close();
	}
	return list;

}
 
开发者ID:gyp220203,项目名称:renren-msg,代码行数:40,代码来源:ParseExcelServiceImpl.java

示例8: createFile

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的package包/类
public void createFile(List<List<Creature>> listList, File file) {
	StringReader reader = new StringReader();
	try {
		HSSFWorkbook workbook = new HSSFWorkbook();
		HSSFSheet sheet1 = workbook.createSheet("Cycle1");
		// Heading
		HSSFRow heading = sheet1.createRow(0);
		for(int j = 0; j < listList.size();j++){
			List<Creature> list = new ArrayList<Creature>(listList.get(j));
		heading.createCell(0+j*13).setCellValue("DNA");
		heading.createCell(1+j*13).setCellValue("LifeExpectancy");
		heading.createCell(2+j*13).setCellValue("Height");
		heading.createCell(3+j*13).setCellValue("Width");
		heading.createCell(4+j*13).setCellValue("Speed");
		heading.createCell(5+j*13).setCellValue("Flight");
		heading.createCell(6+j*13).setCellValue("OptTemperature");
		heading.createCell(7+j*13).setCellValue("NumOffspring");
		heading.createCell(8+j*13).setCellValue("PairChance");
		heading.createCell(9+j*13).setCellValue("Carnivorous");
		heading.createCell(10+j*13).setCellValue("#Environment");
		List<String> uniqueDnaSequence = getAllDnaSequences(list);
		for (int i = 0; i < uniqueDnaSequence.size(); i++) {
			HSSFRow row = sheet1.getRow(i+1);
			if(row == null){
				row= sheet1.createRow(i+1);
			}
			int allelLength = properties.getAllelLength();
			row.createCell(0+j*13).setCellValue(uniqueDnaSequence.get(i));
			row.createCell(1+j*13).setCellValue(reader.readHexStringToInt(uniqueDnaSequence.get(i), 1, allelLength));
			row.createCell(2+j*13).setCellValue(reader.readHexStringToInt(uniqueDnaSequence.get(i), 2, allelLength));
			row.createCell(3+j*13).setCellValue(reader.readHexStringToInt(uniqueDnaSequence.get(i), 3, allelLength));
			row.createCell(4+j*13).setCellValue(reader.readHexStringToInt(uniqueDnaSequence.get(i), 4, allelLength));
			row.createCell(5+j*13).setCellValue(reader.readHexStringToInt(uniqueDnaSequence.get(i), 5, allelLength));
			row.createCell(6+j*13).setCellValue(reader.readHexStringToInt(uniqueDnaSequence.get(i), 6, allelLength));
			row.createCell(7+j*13).setCellValue(reader.readHexStringToInt(uniqueDnaSequence.get(i), 7, allelLength));
			row.createCell(8+j*13).setCellValue(reader.readHexStringToInt(uniqueDnaSequence.get(i), 8, allelLength));
			row.createCell(9+j*13).setCellValue(reader.readHexStringToInt(uniqueDnaSequence.get(i), 9, allelLength));
			row.createCell(10+j*13).setCellValue(j);

		}
		sheet1.autoSizeColumn(0+j*11);
		}
		FileOutputStream out = new FileOutputStream(file);
		workbook.write(out);
		out.close();
		workbook.close();
		System.out.println("Files outputted to c:/EvolutionOutputs");
	} catch (Exception e) {
		System.out.println(e.getMessage());
	}
}
 
开发者ID:Stoephu,项目名称:Evolution-Speciation,代码行数:52,代码来源:DataWrapper.java

示例9: outputResumeProcessResult

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的package包/类
public static void outputResumeProcessResult(Map<File, Resume> map, File outFile) throws IOException {
  //工作簿
  HSSFWorkbook excel = new HSSFWorkbook();
  FileOutputStream fileoutputstream = new FileOutputStream(outFile);
  
  try {
    HSSFSheet sheet = excel.createSheet("简历处理结果");
    
    // 写表头
    HSSFRow headerRow = sheet.createRow(0);
    for(int i = 0; i < HEADERS.length; i++) {
      headerRow.createCell(i).setCellValue(HEADERS[i]);
    }
    
    // 写内容
    int rowNum = 1;
    for(Map.Entry<File, Resume> entry : map.entrySet()) {
      Resume resume = entry.getValue();
      HSSFRow row = sheet.createRow(rowNum);
      row.createCell(0).setCellValue(rowNum);                    // 序号
      row.createCell(1).setCellValue(resume.getName());          // 姓名
      row.createCell(2).setCellValue(resume.getJob());          // 应聘职位
      row.createCell(3).setCellValue(resume.getSource());        // 简历来源
      row.createCell(4).setCellValue(resume.getSchool());        // 毕业院校
      row.createCell(5).setCellValue(resume.getEducation());    // 学历
      row.createCell(6).setCellValue(resume.getAge());           // 年龄
      row.createCell(7).setCellValue(resume.getWorkDuration()); // 工作经验
      row.createCell(8).setCellValue(resume.getCompany());      // 现工作单位
      row.createCell(9).setCellValue(resume.getPhone());         // 电话
      row.createCell(10).setCellValue(resume.getMail());          // 邮箱
      row.createCell(11).setCellValue(resume.getSex());           // 性别
      row.createCell(12).setCellValue(resume.getBirthday());      // 生日
      row.createCell(13).setCellValue(resume.getCity());          // 居住城市
      row.createCell(14).setCellValue(resume.getAddress());       // 地址
      rowNum++;
    }
    excel.write(fileoutputstream);
  } finally {
    fileoutputstream.close();
    excel.close();
  }
}
 
开发者ID:xsocket,项目名称:job,代码行数:43,代码来源:ExcelUtils.java


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