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


Java HSSFWorkbook.write方法代码示例

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


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

示例1: test

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的package包/类
@Test
public void test() throws IOException {
    HSSFWorkbook workbook = createWorkbook();

    byte[] buffer;
    try (ByteArrayOutputStream stream = new ByteArrayOutputStream(1024)) {
        workbook.write(stream);
        stream.flush();
        buffer = stream.toByteArray();
    }

    Map<String, BoundaryPoint> boundaryPoints;
    try (InputStream stream = new ByteArrayInputStream(buffer)) {
        BoundaryPointXlsParser parser = new BoundaryPointXlsParser();
        boundaryPoints = parser.parse(stream);
    }

    assertEquals(1, boundaryPoints.size());
    BoundaryPoint point = boundaryPoints.get("BoundaryPoint FR-BE");
    assertNotNull(point);
    assertEquals("BoundaryPoint FR-BE", point.getName());
    assertEquals(Country.FR, point.getBorderFrom());
    assertEquals(Country.BE, point.getBorderTo());
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:25,代码来源:BoundaryPointXlsParserTest.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 {

    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

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

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

示例6: createExcel

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的package包/类
/** エクセル出力 */
@Execute(validator = false)
public String createExcel(){
	
	ExcelDto dto = new ExcelDto();
	dto.setMeetingName(partyDto.meetingName);
	dto.setMemberList(partyDto.tMemberOn);
	
	HSSFWorkbook wb = excelFpao.excelTemplate(dto);
	
	httpServletResponse.setHeader(
			"Content-Disposition",
			"attachment; filename=" + partyDto.meetingName + System.currentTimeMillis() + ".xls");
	
	try {
		OutputStream out = httpServletResponse.getOutputStream();
		wb.write(out);
	        out.close();		
	} catch (IOException e) {} 	
	
return null;	
}
 
开发者ID:kagucho,项目名称:tsubonesystem2,代码行数:23,代码来源:PartyAttendListAction.java

示例7: createExcel

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的package包/类
/** エクセル出力 */
@Execute(validator = false)
public String createExcel(){
	
	ExcelDto dto = new ExcelDto();	
	dto.setMeetingName(partyDto.meetingName);
	dto.setMemberList(partyDto.tMemberOn);
	
	HSSFWorkbook wb = excelFpao.excelTemplate(dto);
	
	httpServletResponse.setHeader(
			"Content-Disposition",
			"attachment; filename=" + partyDto.meetingName + System.currentTimeMillis() + ".xls");
	
	try {
		OutputStream out = httpServletResponse.getOutputStream();
		wb.write(out);
	        out.close();		
	} catch (IOException e) {} 	
	
return null;	
}
 
开发者ID:kagucho,项目名称:tsubonesystem2,代码行数:23,代码来源:PartyAttendListAction.java

示例8: createExcel

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的package包/类
/**
 * 创建文件
 * @param response
 * @param workbook
 * @param fileName
 * @return boolean
 * @throws Exception
 */
public static boolean createExcel(HttpServletResponse response,
		HSSFWorkbook workbook, String fileName) throws Exception {
	boolean flag = false;
	try {
		response.reset();
		response.setHeader("Content-Disposition", "attachment;filename="
				+ new String(fileName.getBytes(), "iso8859-1"));

		ServletOutputStream out = response.getOutputStream();
		workbook.write(out);
		// 弹出下载对话框
		out.flush();
		out.close();
		flag = true;
	} catch (Exception e) {
		logger.error(fileName + " :文件创建失败");
		throw e;
	}
	return flag;
}
 
开发者ID:wufeisoft,项目名称:data,代码行数:29,代码来源:CreateExcelUtil.java

示例9: writeExcelFile

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的package包/类
public static void writeExcelFile(File excelFile, HSSFWorkbook workbook)
		throws Exception {
	FileOutputStream fos = null;
	BufferedOutputStream bos = null;

	try {
		fos = new FileOutputStream(excelFile);
		bos = new BufferedOutputStream(fos);
		workbook.write(bos);

	} catch (FileNotFoundException e) {
		throw new InputException(e);

	} finally {
		if (bos != null) {
			bos.close();
		}
		if (fos != null) {
			fos.close();
		}
	}
}
 
开发者ID:kozake,项目名称:ermaster-k,代码行数:23,代码来源:POIUtils.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: createExcel

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的package包/类
private void createExcel(OutputStream out, IDocument doc, WebInput wi)
		throws IOException, ServletException {
	this.setContentType("application/vnd.ms-excel");
	HSSFWorkbook wb = new HSSFWorkbook();
	DocInfo di = new DocInfo(IDocument.TYPE_MS_EXCEL);
	try {
		di.setExcelDocument(wb);
		doc.createContent(wi, di);
		wb.write(out);
	} catch (Exception e) {
		throw new ServletException(e);
	} finally {
		if (out != null) {
			out.flush();
			out.close();
			out = null;
		}
		di = null;
		doc = null;
		wb = null;
	}
}
 
开发者ID:jbeetle,项目名称:BJAF3.x,代码行数:23,代码来源:DocumentController.java

示例12: writeExcelFile

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的package包/类
public static void writeExcelFile(final File excelFile, final HSSFWorkbook workbook) throws Exception {
    FileOutputStream fos = null;
    BufferedOutputStream bos = null;

    try {
        fos = new FileOutputStream(excelFile);
        bos = new BufferedOutputStream(fos);
        workbook.write(bos);

    } catch (final FileNotFoundException e) {
        throw new InputException(e);

    } finally {
        if (bos != null) {
            bos.close();
        }
        if (fos != null) {
            fos.close();
        }
    }
}
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:22,代码来源:POIUtils.java

示例13: createExcel

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的package包/类
/**
 * 创建文件
 * @param response
 * @param workbook
 * @param fileName
 * @return boolean
 * @throws Exception
 */
public static  FileTransfer createExcel(HttpServletResponse response,
		HSSFWorkbook workbook, String fileName) throws Exception {
	boolean flag = false;
	try {
		response.reset();
		response.setHeader("Content-Disposition", "attachment;filename="
				+ new String(fileName.getBytes(), "iso8859-1"));

		//ServletOutputStream out = response.getOutputStream();
		ByteArrayOutputStream buffer = new ByteArrayOutputStream();
		workbook.write(buffer);
		return new FileTransfer(fileName, "application/vnd.ms-excel", buffer.toByteArray());
		// 弹出下载对话框
		//out.flush();
		//out.close();
		//flag = true;
	} catch (Exception e) {
		logger.error(fileName + " :文件创建失败");
		throw e;
	}
	//return flag;
}
 
开发者ID:wufeisoft,项目名称:ryf_mms2,代码行数:31,代码来源:CreateExcelUtil.java

示例14: exportInnertion

import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的package包/类
@Override
   public void exportInnertion(OutputStream servletOut, List header,
		List data) throws IOException {
	if (header == null || header.isEmpty()) {
		return;
	}
	HSSFWorkbook workbook = ExcelUtil.export(header, data);
	workbook.write(servletOut);

}
 
开发者ID:fellyvon,项目名称:wasexport,代码行数:11,代码来源:ExcelExport.java

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


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