Package jxl

Examples of jxl.Workbook


    excelView.setApplicationContext(webAppCtx);
    excelView.setUrl("template");
    excelView.render(new HashMap<String, Object>(), request, response);

    Workbook wb = Workbook.getWorkbook(new ByteArrayInputStream(response.getContentAsByteArray()));
    Sheet sheet = wb.getSheet("Sheet1");
    Cell cell = sheet.getCell(0, 0);
    assertEquals("Test Template", cell.getContents());
  }
View Full Code Here


    excelView.setApplicationContext(webAppCtx);
    excelView.setUrl("template");
    excelView.render(new HashMap<String, Object>(), request, response);

    Workbook wb = Workbook.getWorkbook(new ByteArrayInputStream(response.getContentAsByteArray()));
    Sheet sheet = wb.getSheet("Sheet1");
    Cell cell = sheet.getCell(0, 0);
    assertEquals("Test Template American English", cell.getContents());
  }
View Full Code Here

    excelView.setApplicationContext(webAppCtx);
    excelView.setUrl("template");
    excelView.render(new HashMap<String, Object>(), request, response);

    Workbook wb = Workbook.getWorkbook(new ByteArrayInputStream(response.getContentAsByteArray()));
    Sheet sheet = wb.getSheet("Sheet1");
    Cell cell = sheet.getCell(0, 0);
    assertEquals("Test Template auf Deutsch", cell.getContents());
  }
View Full Code Here

   */
  private static abstract class UnixSafeAbstractJExcelView extends AbstractJExcelView {

    @Override
    protected Workbook getTemplateSource(String url, HttpServletRequest request) throws Exception {
      Workbook workbook = super.getTemplateSource(url, request);
      Field field = WorkbookParser.class.getDeclaredField("settings");
      field.setAccessible(true);
      WorkbookSettings settings = (WorkbookSettings) ReflectionUtils.getField(field, workbook);
      settings.setWriteAccess(null);
      return workbook;
View Full Code Here

    response.setContentType(getContentType());
    OutputStream out = response.getOutputStream();

    WritableWorkbook workbook;
    if (this.url != null) {
      Workbook template = getTemplateSource(this.url, request);
      workbook = Workbook.createWorkbook(out, template);
    }
    else {
      logger.debug("Creating Excel Workbook from scratch");
      workbook = Workbook.createWorkbook(out);
View Full Code Here

   * @throws BiffException
   * @throws IOException
   */
  public List read(int pBegin) throws BiffException, IOException{
    List list = new ArrayList();
    Workbook workbook = Workbook.getWorkbook(getIs());
    Sheet sheet = workbook.getSheet(0);
    int rows = sheet.getRows();
    for (int i = pBegin; i < rows; i++) {
      Dto rowDto = new BaseDto();
      Cell[] cells = sheet.getRow(i);
      for (int j = 0; j < cells.length; j++) {
View Full Code Here

   * @throws BiffException
   * @throws IOException
   */
  public List read(int pBegin, int pBack) throws BiffException, IOException{
    List list = new ArrayList();
    Workbook workbook = Workbook.getWorkbook(getIs());
    Sheet sheet = workbook.getSheet(0);
    int rows = sheet.getRows();
    for (int i = pBegin; i < rows - pBack; i++) {
      Dto rowDto = new BaseDto();
      Cell[] cells = sheet.getRow(i);
      String[] arrMeta = getMetaData().trim().split(",");
View Full Code Here

    //templatePath = request.getSession().getServletContext().getRealPath(templatePath);
        InputStream is = request.getSession().getServletContext().getResourceAsStream(templatePath);
    if(G4Utils.isEmpty(is)){
      log.error(G4Constants.Exception_Head + "未找到模板文件,请确认模板路径是否正确[" + templatePath + "]");
    }
    Workbook workbook = null;
    try {
      workbook = Workbook.getWorkbook(is);
    } catch (Exception e) {
      e.printStackTrace();
    }
    Sheet sheet = workbook.getSheet(0);
    if (G4Utils.isNotEmpty(sheet)) {
      int rows = sheet.getRows();
      for (int k = 0; k < rows; k++) {
        Cell[] cells = sheet.getRow(k);
        for (int j = 0; j < cells.length; j++) {
View Full Code Here

  public ByteArrayOutputStream fill(HttpServletRequest request) {
    WritableSheet wSheet = null;
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    try {
          InputStream is = request.getSession().getServletContext().getResourceAsStream(getExcelTemplate().getTemplatePath());
      Workbook wb = Workbook.getWorkbook(is);
      WritableWorkbook wwb = Workbook.createWorkbook(bos, wb);
      wSheet = wwb.getSheet(0);
      fillStatics(wSheet);
      fillParameters(wSheet);
      fillFields(wSheet);
      if (G4Utils.isNotEmpty(getExcelData().getFieldsList())) {
        // fillFields(wSheet);
      }
      wwb.write();
      wwb.close();
      wb.close();
    } catch (Exception e) {
      log.error(G4Constants.Exception_Head + "基于模板生成可写工作表出错了!");
      e.printStackTrace();
    }
    return bos;
View Full Code Here

        this._useFirstSheet = true;
    }

    public void parseFile(InputStream inStream) {
        try {
            Workbook workbook = Workbook.getWorkbook( inStream );

            if ( _useFirstSheet ) {
                Sheet sheet = workbook.getSheet( 0 );
                processSheet( sheet,
                              _listeners.get( DEFAULT_RULESHEET_NAME ) );
            } else {
                for ( String sheetName : _listeners.keySet() ) {
                    Sheet sheet = workbook.getSheet( sheetName );
                    processSheet( sheet,
                                  _listeners.get( sheetName ) );

                }
            }
View Full Code Here

TOP

Related Classes of jxl.Workbook

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.