Example usage for org.apache.poi.ss.usermodel Sheet getRow

List of usage examples for org.apache.poi.ss.usermodel Sheet getRow

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel Sheet getRow.

Prototype

Row getRow(int rownum);

Source Link

Document

Returns the logical row (not physical) 0-based.

Usage

From source file:com.dataart.spreadsheetanalytics.engine.graph.PoiDependencyGraphBuilder.java

License:Apache License

public static IExecutionGraph buildDependencyGraph(IDataModel dataModel, IA1Address cell) {
    if (dataModel == null) {
        throw new CalculationEngineException("DataModel and PoiModel are required to build dependency graph");
    }/*from   www . j a  v a2 s .  com*/

    PoiDependencyGraphBuilder db = new PoiDependencyGraphBuilder(dataModel);

    Sheet s = db.poiBook.getSheetAt(0); //TODO: works for only one sheet workbooks
    if (s == null) {
        return null;
    }
    Row r = s.getRow(cell.row());
    if (r == null) {
        return null;
    }
    Cell c = r.getCell(cell.column());
    if (c == null) {
        return null;
    }

    ExecutionGraphVertex v = ExecutionGraph
            .createVertex(A1Address.fromRowColumn(c.getRowIndex(), c.getColumnIndex()).address());
    db.state.addVertex(v);

    if (CELL_TYPE_FORMULA == c.getCellType()) {
        db.collect(v, c.getCellFormula());
    }

    return db.state;
}

From source file:com.dataart.spreadsheetanalytics.engine.PoiWorkbookConverters.java

License:Apache License

private PoiProxySheet makeSheet(Workbook wb, FormulaParsingWorkbook ewb) {
    Sheet wbSheet = wb.getSheetAt(0);
    PoiProxySheet sheet = new PoiProxySheet(wbSheet.getSheetName());

    for (int r = 0; r <= wbSheet.getLastRowNum(); r++) {
        Row wbSheetRow = wbSheet.getRow(r);
        if (wbSheetRow == null) {
            continue;
        }//from   w  w  w.j a v  a 2  s  .co m

        for (int c = 0; c <= wbSheetRow.getLastCellNum(); c++) {
            Cell wbSheetRowCell = wbSheetRow.getCell(c);
            if (wbSheetRowCell == null) {
                continue;
            }

            final Ptg[] tokens = CELL_TYPE_FORMULA == wbSheetRowCell.getCellType()
                    ? FormulaParser.parse(wbSheetRowCell.getCellFormula(), ewb, FormulaType.CELL, 0)
                    : null;
            sheet.setCell(PoiProxyCell.makeCell(sheet, wbSheetRowCell, tokens));
        }
    }

    return sheet;
}

From source file:com.dataart.spreadsheetanalytics.functions.poi.data.FuncexecFunction.java

License:Apache License

@Override
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {

    log.debug("In evaluate() of FUNCEXEC function. Args = {}", Arrays.toString(args));

    if (!(args[0] instanceof StringEval) && !(args[0] instanceof RefEval)) {
        log.warn(/*from w  w w . j  av a 2  s .  c om*/
                "The first argument of FUNCEXEC function must be a string (or a reference to a cell) - name of DEFINE function.");
        return ErrorEval.VALUE_INVALID;
    }

    String defineFunctionName;
    try {
        defineFunctionName = (String) coerceValueTo(
                getSingleValue(args[0], ec.getRowIndex(), ec.getColumnIndex()));
    } catch (EvaluationException e) {
        log.error(String.format("Cannot get the value of DEFINE functuion name: %s", args[0]), e);
        return ErrorEval.VALUE_INVALID;
    }
    defineFunctionName = defineFunctionName.toUpperCase(Locale.getDefault());

    MetaFunctionAccessor defines = (MetaFunctionAccessor) ec.getCustomEvaluationContext()
            .get(MetaFunctionAccessor.class);
    if (defines == null) {
        defines = this.external.getMetaFunctionAccessor();
    }

    if (defines.get(defineFunctionName) == null) {
        log.warn("No DEFINE function with name {} is found.", defineFunctionName);
        return ErrorEval.NAME_INVALID;
    }

    List<ValueEval> inputValues = new LinkedList<>();
    List<ValueEval> inArgs = new ArrayList(Arrays.asList(args));
    inArgs.remove(0); //remove define function name

    try {
        for (ValueEval v : ICustomFunction.prepareQueryArgs(inArgs)) {
            inputValues.add(getSingleValue(v, ec.getRowIndex(), ec.getColumnIndex()));
        }
    } catch (EvaluationException e) {
        log.error("Cannot resolve input values for FUNCEXEC function", e);
        return ErrorEval.VALUE_INVALID;
    }

    final DefineFunctionMeta meta = (DefineFunctionMeta) defines.get(defineFunctionName);
    log.info("Found DEFINE function to invoke. Name = {}.", defineFunctionName);

    if (meta.getInputs().size() != inputValues.size()) {
        log.warn("Wrong number of input arguments for FUNCEXEC+DEFINE. Expected: {}, Actual: {}.",
                meta.getInputs().size(), args.length - 1);
        return ErrorEval.VALUE_INVALID;
    }

    List<IA1Address> inputAddresses = meta.getInputs();
    log.debug("Input Addresses for DEFINE: {}, Input Values for DEFINE: {}.", inputAddresses, inputValues);

    if (inputAddresses.size() != inputValues.size()) {
        log.warn("Wrong number of input arguments for {} function.", defineFunctionName);
        return ErrorEval.VALUE_INVALID;
    }

    DataModelAccessor dataModels = (DataModelAccessor) ec.getCustomEvaluationContext()
            .get(DataModelAccessor.class);
    if (dataModels == null) {
        dataModels = this.external.getDataModelAccessor();
    }

    IDataModel dmWithDefine = dataModels.get(meta.getDataModelId());

    Workbook book = toWorkbook(dmWithDefine);
    EvaluationWorkbook defineBook = toEvaluationWorkbook(book);

    Sheet s = book.getSheetAt(0); //TODO one sheet support
    for (int i = 0; i < inputAddresses.size(); i++) {

        Row defineRow = s.getRow(inputAddresses.get(i).row());
        if (defineRow == null) {
            defineRow = s.createRow(inputAddresses.get(i).row());
        }
        Cell defineCell = defineRow.getCell(inputAddresses.get(i).column());
        if (defineCell == null) {
            defineCell = defineRow.createCell(inputAddresses.get(i).column());
        }

        populateCellValue(defineCell, inputValues.get(i));
        updateCell(defineBook, defineCell);
    }

    WorkbookEvaluator defineEvaluator = new WorkbookEvaluator(defineBook,
            IStabilityClassifier.TOTALLY_IMMUTABLE, null);
    List<ValueEval> outputValues = meta.getOutputs().stream().map(
            a -> defineEvaluator.evaluate(getEvaluationCell(defineBook, a), ec.getCustomEvaluationContext()))
            .collect(Collectors.<ValueEval>toList());

    log.debug("Output Values of DEFINE execution: {}.", outputValues);

    return outputValues.size() == 1 ? outputValues.get(0) : toArrayEval(outputValues);
}

From source file:com.delpac.bean.CargarSellosBean.java

public List<Sellos> importData(Workbook workbook, int tabNumber) throws IOException {
    List<Sellos> lista = new ArrayList<>();
    String[][] data;/*from  w w w  .j  a  v  a  2 s  .c om*/
    Sheet sheet = workbook.getSheetAt(tabNumber);
    data = new String[sheet.getLastRowNum() + 1][];
    Row[] row = new Row[sheet.getLastRowNum() + 1];
    Cell[][] cell = new Cell[row.length][];

    for (int i = 1; i < row.length; i++) {
        row[i] = sheet.getRow(i);
        cell[i] = new Cell[row[i].getLastCellNum()];
        data[i] = new String[row[i].getLastCellNum()];
        Sellos sellos = new Sellos();
        for (int j = 0; j < cell[i].length; j++) {
            cell[i][j] = row[i].getCell(j);
            if (cell[i][j] != null) {
                switch (j) {
                case 0:
                    sellos.setInv_seguridad(getDataFromCell(cell, i, j));
                    break;
                case 1:
                    sellos.setInv_sello(getDataFromCell(cell, i, j));
                    break;
                }
            } else {
                switch (j) {
                case 0:
                    sellos.setInv_seguridad("");
                    break;
                case 1:
                    sellos.setInv_sello("");
                    break;
                }
            }
        }
        if (!"".equals(sellos.getInv_sello())) {
            lista.add(sellos);
        }
    }

    return lista;
}

From source file:com.delpac.bean.PreDescargaBean.java

public List<PreDescarga> importData(Workbook workbook, int tabNumber) throws IOException {
    List<PreDescarga> lista = new ArrayList<>();
    String[][] data;//from   www. jav a 2s.  c  o  m
    DataFormatter df = new DataFormatter();
    Sheet sheet = workbook.getSheetAt(tabNumber);
    data = new String[sheet.getLastRowNum() + 1][];
    Row[] row = new Row[sheet.getLastRowNum() + 1];
    Cell[][] cell = new Cell[row.length][];

    for (int i = 1; i < row.length; i++) {
        row[i] = sheet.getRow(i);
        cell[i] = new Cell[row[i].getLastCellNum()];
        data[i] = new String[row[i].getLastCellNum()];
        PreDescarga preDescarga = new PreDescarga();
        for (int j = 0; j < cell[i].length; j++) {
            cell[i][j] = row[i].getCell(j);
            if (cell[i][j] != null) {
                switch (j) {
                case 0:
                    preDescarga.setBl(getDataFromCell(cell, i, j));
                    break;
                case 1:
                    preDescarga.setConsignatario(getDataFromCell(cell, i, j));
                    break;
                case 2:
                    preDescarga.setPto_origen(getDataFromCell(cell, i, j));
                    break;
                case 3:
                    preDescarga.setPto_destino(getDataFromCell(cell, i, j));
                    break;
                case 4:
                    preDescarga.setFec_embarque(getDataFromCell(cell, i, j));
                    break;
                case 5:
                    preDescarga.setPeso(Double.parseDouble(getDataFromCell(cell, i, j)));
                    break;
                case 6:
                    preDescarga.setBulto(Double.parseDouble(getDataFromCell(cell, i, j)));
                    break;
                case 7:
                    preDescarga.setEmbalaje(getDataFromCell(cell, i, j));
                    break;
                case 8:
                    preDescarga.setCarga(getDataFromCell(cell, i, j));
                    break;
                case 9:
                    preDescarga.setCon_codigo(getDataFromCell(cell, i, j));
                    break;
                case 10:
                    preDescarga.setTemperatura(getDataFromCell(cell, i, j));
                    break;
                case 11:
                    preDescarga.setVentilacion(getDataFromCell(cell, i, j));
                    break;
                case 12:
                    preDescarga.setSello(getDataFromCell(cell, i, j));
                    break;
                case 13:
                    preDescarga.setSown(getDataFromCell(cell, i, j));
                    break;
                case 14:
                    preDescarga.setClassimo(getDataFromCell(cell, i, j));
                    break;
                case 15:
                    preDescarga.setUnnro(getDataFromCell(cell, i, j));
                    break;
                case 16:
                    preDescarga.setTip_cont(getDataFromCell(cell, i, j));
                    break;
                case 17:
                    preDescarga.setCondicion(getDataFromCell(cell, i, j));
                    break;
                case 18:
                    preDescarga.setAlm_codigo(getDataFromCell(cell, i, j));
                    break;
                }
            } else {
                switch (j) {
                case 1:
                    preDescarga.setBl("");
                    break;
                case 2:
                    preDescarga.setConsignatario("");
                    break;
                case 3:
                    preDescarga.setPto_origen("");
                    break;
                case 4:
                    preDescarga.setPto_destino("");
                    break;
                case 5:
                    preDescarga.setFec_embarque("");
                    break;
                case 6:
                    preDescarga.setPeso(0);
                    break;
                case 7:
                    preDescarga.setBulto(0);
                    break;
                case 8:
                    preDescarga.setEmbalaje("");
                    break;
                case 9:
                    preDescarga.setCarga("");
                    break;
                case 10:
                    preDescarga.setCon_codigo("");
                    break;
                case 11:
                    preDescarga.setTemperatura("");
                    break;
                case 12:
                    preDescarga.setVentilacion("");
                    break;
                case 13:
                    preDescarga.setSello("");
                    break;
                case 14:
                    preDescarga.setSown("");
                    break;
                case 15:
                    preDescarga.setClassimo("");
                    break;
                case 16:
                    preDescarga.setUnnro("");
                    break;
                case 17:
                    preDescarga.setTip_cont("");
                    break;
                case 18:
                    preDescarga.setCondicion("");
                    break;
                case 19:
                    preDescarga.setAlm_codigo("");
                    break;
                }
            }
        }
        lista.add(preDescarga);
    }
    return lista;
}

From source file:com.devnexus.ting.web.controller.admin.RegistrationController.java

License:Apache License

@RequestMapping(value = "/s/admin/{eventKey}/uploadRegistration", method = RequestMethod.POST)
public ModelAndView uploadGroupRegistration(ModelAndView model, HttpServletRequest request,
        @PathVariable(value = "eventKey") String eventKey,
        @Valid @ModelAttribute("registerForm") UploadGroupRegistrationForm uploadForm,
        BindingResult bindingResult) throws FileNotFoundException, IOException, InvalidFormatException {

    EventSignup signUp = eventSignupRepository.getByEventKey(eventKey);
    model.getModelMap().addAttribute("event", signUp.getEvent());

    if (bindingResult.hasErrors()) {

        model.getModelMap().addAttribute("registerForm", uploadForm);
        model.setViewName("/admin/upload-registration");
    } else {/*from  w w  w  . j  a  v a 2s. co  m*/

        boolean hasErrors = false;

        try {

            Workbook wb = WorkbookFactory.create(uploadForm.getRegistrationFile().getInputStream());
            Sheet sheet = wb.getSheetAt(0);
            Cell contactNameCell = sheet.getRow(0).getCell(1, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
            Cell contactEmailCell = sheet.getRow(1).getCell(1, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
            Cell contactPhoneCell = sheet.getRow(2).getCell(1, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
            Cell registrationReferenceCell = sheet.getRow(3).getCell(1,
                    Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);

            if (contactNameCell.getStringCellValue().isEmpty()) {
                hasErrors = true;
                bindingResult.addError(new ObjectError("registrationFile", "Contact Name Empty"));
            }

            if (contactEmailCell.getStringCellValue().isEmpty()) {
                hasErrors = true;
                bindingResult.addError(new ObjectError("registrationFile", "Contact Email Empty"));
            }

            if (contactPhoneCell.getStringCellValue().isEmpty()) {
                hasErrors = true;
                bindingResult.addError(new ObjectError("registrationFile", "Contact Phone Empty"));
            }

            if (registrationReferenceCell.getStringCellValue().isEmpty()) {
                hasErrors = true;
                bindingResult.addError(new ObjectError("registrationFile", "Registration Reference Empty"));
            }

            if (!hasErrors) {
                RegistrationDetails details = new RegistrationDetails();
                details.setContactEmailAddress(contactEmailCell.getStringCellValue());
                details.setContactName(contactNameCell.getStringCellValue());
                details.setContactPhoneNumber(contactPhoneCell.getStringCellValue());
                details.setRegistrationFormKey(registrationReferenceCell.getStringCellValue());
                details.setEvent(signUp.getEvent());
                details.setFinalCost(BigDecimal.ZERO);
                details.setInvoice("Invoiced");
                details.setPaymentState(RegistrationDetails.PaymentState.PAID);
                int attendeeRowIndex = 7;

                Row attendeeRow = sheet.getRow(attendeeRowIndex);
                while (attendeeRow != null) {
                    attendeeRow = sheet.getRow(attendeeRowIndex);
                    if (attendeeRow != null) {
                        Cell firstName = attendeeRow.getCell(0, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
                        Cell lastName = attendeeRow.getCell(1, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
                        Cell emailAddress = attendeeRow.getCell(2, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
                        Cell city = attendeeRow.getCell(3, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
                        Cell state = attendeeRow.getCell(4, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
                        Cell country = attendeeRow.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
                        Cell ticketType = attendeeRow.getCell(6, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
                        Cell company = attendeeRow.getCell(7, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
                        Cell jobTitle = attendeeRow.getCell(8, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
                        Cell tshirtSize = attendeeRow.getCell(9, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
                        Cell vegetarian = attendeeRow.getCell(10, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
                        Cell sponsorMessages = attendeeRow.getCell(11,
                                Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);

                        if (firstName.getStringCellValue().isEmpty()) {
                            break;
                        }

                        if (lastName.getStringCellValue().isEmpty()) {
                            bindingResult.addError(new ObjectError("registrationFile",
                                    " row " + (attendeeRowIndex + 1) + " missing information : lastName"));
                            hasErrors = true;
                            break;
                        }
                        if (emailAddress.getStringCellValue().isEmpty()) {
                            bindingResult.addError(new ObjectError("registrationFile",
                                    " row " + (attendeeRowIndex + 1) + " missing information : emailAddress"));
                            hasErrors = true;
                            break;
                        }
                        if (city.getStringCellValue().isEmpty()) {
                            bindingResult.addError(new ObjectError("registrationFile",
                                    " row " + (attendeeRowIndex + 1) + " missing information : city"));
                            hasErrors = true;
                            break;
                        }
                        if (state.getStringCellValue().isEmpty()) {
                            bindingResult.addError(new ObjectError("registrationFile",
                                    " row " + (attendeeRowIndex + 1) + " missing information : state "));
                            hasErrors = true;
                            break;
                        }
                        if (country.getStringCellValue().isEmpty()) {
                            bindingResult.addError(new ObjectError("registrationFile",
                                    " row " + (attendeeRowIndex + 1) + " missing information : country"));
                            hasErrors = true;
                            break;
                        }
                        if (company.getStringCellValue().isEmpty()) {
                            bindingResult.addError(new ObjectError("registrationFile",
                                    " row " + (attendeeRowIndex + 1) + " missing information : company"));
                            hasErrors = true;
                            break;
                        }
                        if (jobTitle.getStringCellValue().isEmpty()) {
                            bindingResult.addError(new ObjectError("registrationFile",
                                    " row " + (attendeeRowIndex + 1) + " missing information : jobTitle"));
                            hasErrors = true;
                            break;
                        }

                        if (ticketType.getStringCellValue().isEmpty()) {
                            bindingResult.addError(new ObjectError("registrationFile",
                                    " row " + (attendeeRowIndex + 1) + " missing information: ticket type"));
                            hasErrors = true;
                            break;
                        }

                        if (tshirtSize.getStringCellValue().isEmpty()) {
                            bindingResult.addError(new ObjectError("registrationFile",
                                    " row " + (attendeeRowIndex + 1) + " missing information: t shirt "));
                            hasErrors = true;
                            break;
                        }
                        if (vegetarian.getStringCellValue().isEmpty()
                                || !(vegetarian.getStringCellValue().equalsIgnoreCase("no")
                                        || vegetarian.getStringCellValue().equalsIgnoreCase("yes"))) {
                            bindingResult.addError(
                                    new ObjectError("registrationFile", " row " + (attendeeRowIndex + 1)
                                            + " missing information. Vegetarian option should be yes or no "));
                            hasErrors = true;
                            break;
                        }
                        if (sponsorMessages.getStringCellValue().isEmpty()
                                || !(sponsorMessages.getStringCellValue().equalsIgnoreCase("no")
                                        || sponsorMessages.getStringCellValue().equalsIgnoreCase("yes"))) {
                            bindingResult.addError(
                                    new ObjectError("registrationFile", " row " + (attendeeRowIndex + 1)
                                            + " missing information. Sponsor message should be yes or no "));
                            hasErrors = true;
                            break;
                        }

                        TicketOrderDetail detail = new TicketOrderDetail();

                        detail.setCity(city.getStringCellValue());
                        detail.setCompany(company.getStringCellValue());
                        detail.setCouponCode("");
                        detail.setCountry(country.getStringCellValue());
                        detail.setEmailAddress(emailAddress.getStringCellValue());
                        detail.setFirstName(firstName.getStringCellValue());
                        detail.setJobTitle(jobTitle.getStringCellValue());
                        detail.setLastName(lastName.getStringCellValue());
                        detail.setSponsorMayContact(
                                sponsorMessages.getStringCellValue().equalsIgnoreCase("no") ? "false" : "true");
                        detail.setState(state.getStringCellValue());
                        detail.setTicketGroup(
                                Long.parseLong(ticketType.getStringCellValue().split("-\\|-")[1].trim()));

                        detail.setLabel(businessService.getTicketGroup(detail.getTicketGroup()).getLabel());

                        detail.settShirtSize(tshirtSize.getStringCellValue());
                        detail.setVegetarian(
                                vegetarian.getStringCellValue().equalsIgnoreCase("no") ? "false" : "true");
                        detail.setRegistration(details);
                        details.getOrderDetails().add(detail);

                        attendeeRowIndex++;

                    }
                }

                if (uploadForm.getOverrideRegistration()) {
                    try {
                        RegistrationDetails tempRegistration = businessService
                                .getRegistrationForm(registrationReferenceCell.getStringCellValue());
                        tempRegistration.getOrderDetails().forEach((oldDetail) -> {
                            oldDetail.setRegistration(null);
                        });
                        tempRegistration.getOrderDetails().clear();
                        tempRegistration.getOrderDetails().addAll(details.getOrderDetails());

                        tempRegistration.getOrderDetails().forEach((detail) -> {
                            detail.setRegistration(tempRegistration);
                        });
                        details = tempRegistration;

                        businessService.updateRegistration(details, uploadForm.getSendEmail());
                    } catch (EmptyResultDataAccessException ignore) {
                        businessService.updateRegistration(details, uploadForm.getSendEmail());
                    }
                } else {
                    try {
                        RegistrationDetails tempRegistration = businessService
                                .getRegistrationForm(registrationReferenceCell.getStringCellValue());
                        hasErrors = true;
                        bindingResult.addError(new ObjectError("registrationFile",
                                "Registration with this key exists, please check \"Replace Registrations\"."));
                    } catch (EmptyResultDataAccessException ignore) {
                        businessService.updateRegistration(details, uploadForm.getSendEmail());
                    }
                }

            }

        } catch (Exception ex) {
            hasErrors = true;
            Logger.getAnonymousLogger().log(Level.SEVERE, ex.getMessage(), ex);

            bindingResult.addError(new ObjectError("registrationFile", ex.getMessage()));
        }
        if (hasErrors) {
            model.setViewName("/admin/upload-registration");
        } else {
            model.setViewName("/admin/index");
        }
    }

    return model;
}

From source file:com.devnexus.ting.web.controller.admin.RegistrationController.java

License:Apache License

@RequestMapping(value = "/s/admin/{eventKey}/groupRegistration", method = RequestMethod.POST)
public ModelAndView downloadGroupRegistration(ModelAndView model, HttpServletRequest request,
        @PathVariable(value = "eventKey") String eventKey, @Valid RegisterForm form, BindingResult result)
        throws FileNotFoundException, IOException, InvalidFormatException {

    EventSignup signUp = eventSignupRepository.getByEventKey(eventKey);

    model.getModelMap().addAttribute("event", signUp.getEvent());
    model.getModelMap().addAttribute("registerForm", form);

    if (!result.hasErrors()) {
        Workbook workbook = WorkbookFactory
                .create(getClass().getResourceAsStream("/forms/registration_form.xlsx"));
        Sheet formSheet = workbook.getSheetAt(0);
        Sheet ticketTypeSheet = workbook.createSheet("ticket_types");

        Row contactNameRow = formSheet.getRow(0);
        Row contactEmailRow = formSheet.getRow(1);
        Row contactPhoneRow = formSheet.getRow(2);
        Row registrationReferenceRow = formSheet.getRow(3);

        String[] ticketTypes = formatTicketTypes(signUp);
        addTicketTypesToSheet(ticketTypes, ticketTypeSheet);

        contactNameRow.createCell(1).setCellValue(form.getContactName());
        contactEmailRow.createCell(1).setCellValue(form.getContactEmailAddress());
        contactPhoneRow.createCell(1).setCellValue(form.getContactPhoneNumber());
        registrationReferenceRow.createCell(1).setCellValue(UUID.randomUUID().toString());

        createTicketTypeDropDown(formSheet, ticketTypeSheet, ticketTypes);

        model.setView(new BulkRegistrationFormView(workbook,
                form.getContactName().replace(" ", "_") + "RegistrationFile.xlsx"));
    } else {/*from   w w  w.  j  a v  a2 s. c om*/
        model.setViewName("/admin/group-registration");
    }
    return model;
}

From source file:com.dituiba.excel.BaseExcelService.java

License:Apache License

/***
 * ?hash?Excel/*  w w w .  j a  v a2 s.c o  m*/
 * @param sheet
 * @param hashCode
 */
public static void setHashVal(Sheet sheet, long hashCode) {
    Row sheetRow = sheet.getRow(HASH_ROW);
    Cell cell = sheetRow.createCell(0);
    cell.setCellValue(hashCode);
    sheetRow.setHeight(Short.valueOf("0"));
}

From source file:com.dituiba.excel.BaseExcelService.java

License:Apache License

/**
 * ??hash?/*from w  w  w. ja  va2  s. c  om*/
 * @param sheet
 * @return
 */
public static long getHashVal(Sheet sheet) {
    Row sheetRow = sheet.getRow(HASH_ROW);
    Cell cell = sheetRow.getCell(0);
    return ((Double) cell.getNumericCellValue()).longValue();
}

From source file:com.dituiba.excel.BaseExcelService.java

License:Apache License

/**
 * ??//from  ww w.  j  av  a2  s.co  m
 * @param sheet
 * @param row
 * @param col
 * @return
 */
public static Cell getCell(Sheet sheet, int row, int col) {
    return sheet.getRow(row).getCell(col);
}