Example usage for org.apache.poi.xssf.usermodel XSSFWorkbook getSheetAt

List of usage examples for org.apache.poi.xssf.usermodel XSSFWorkbook getSheetAt

Introduction

In this page you can find the example usage for org.apache.poi.xssf.usermodel XSSFWorkbook getSheetAt.

Prototype

@Override
public XSSFSheet getSheetAt(int index) 

Source Link

Document

Get the XSSFSheet object at the given index.

Usage

From source file:org.keyboardplaying.xtt.xlsx.XlsxNormalizerTest.java

License:Apache License

private void controlSheet(XSSFWorkbook workbook, String range, int sheetIndex) {
    XSSFSheet sheet = workbook.getSheetAt(sheetIndex);
    if (sheet.getPaneInformation() == null) {
        // Doesn't work with panes
        assertEquals(new CellAddress(range), sheet.getActiveCell());
    }//  w  w  w .j a v a 2 s  .c  o  m
    assertEquals(0, sheet.getTopRow());
    assertEquals(0, sheet.getLeftCol());
    assertFalse(sheet.isDisplayGridlines());
    assertFalse(sheet.isSelected());
}

From source file:org.kitodo.production.plugin.importer.massimport.PicaMassImport.java

License:Open Source License

private List<Record> getRecordsForXLSX(InputStream xls) throws IOException {
    List<Record> records = new ArrayList<>();

    XSSFWorkbook wb = new XSSFWorkbook(xls);
    XSSFSheet sheet = wb.getSheetAt(0); // first sheet
    // loop over all rows
    for (int j = 0; j <= sheet.getLastRowNum(); j++) {
        // loop over all cells
        XSSFRow row = sheet.getRow(j);/*w w w . j  av a 2s .c  om*/
        if (Objects.nonNull(row)) {
            for (int i = 0; i < row.getLastCellNum(); i++) {
                XSSFCell cell = row.getCell(i);
                // changing all cell types to String
                cell.setCellType(HSSFCell.CELL_TYPE_STRING);
                Record record = changeCellTypeToString(cell, i, j);
                if (Objects.nonNull(record)) {
                    records.add(record);
                }
            }
        }
    }

    return records;
}

From source file:org.natica.expense.ExpenseUtility.java

public List<Expense> parseExcel(File file) throws IOException, ExpenseExcelFormatException {
    List<Expense> expenses = new ArrayList<Expense>();
    FileInputStream fis;//from  w w w .j  a v a2s.  c o m

    fis = new FileInputStream(file);
    XSSFWorkbook wb;

    wb = new XSSFWorkbook(fis);
    XSSFSheet sh = wb.getSheetAt(0);

    for (Row row : sh) {
        if (row.getRowNum() == 0) {
            if (!checkHeaderRow(sh.getRow(0)))
                throw new ExpenseExcelFormatException("Excel Balk simleri Hataldr.");
            else
                continue;
        }
        Expense e = new Expense();
        for (Cell cell : row) {
            if (cell.getColumnIndex() == 0) {
                if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
                    if (!HSSFDateUtil.isCellDateFormatted(cell)) {
                        throw new ExpenseExcelFormatException("Hatal veri! Satr:" + row.getRowNum()
                                + " Stun:" + cell.getColumnIndex() + " Hata Nedeni: Veri tipi tarih deil");
                    }
                } else {
                    throw new ExpenseExcelFormatException("Hatal veri! Satr:" + row.getRowNum() + " Stun:"
                            + cell.getColumnIndex() + " Hata Nedeni: Veri tipi tarih deil");
                }
                e.setExpenseEntryDate(cell.getDateCellValue());
            } else if (cell.getColumnIndex() == 1) {
                if (cell.getCellType() != Cell.CELL_TYPE_STRING) {
                    throw new ExpenseExcelFormatException("Hatal veri! Satr:" + row.getRowNum() + " Stun:"
                            + cell.getColumnIndex() + " Hata Nedeni: Veri tipi yaz deil");
                }
                e.setProjectName(cell.getStringCellValue());
            } else if (cell.getColumnIndex() == 2) {
                if (cell.getCellType() != Cell.CELL_TYPE_STRING) {
                    throw new ExpenseExcelFormatException("Hatal veri! Satr:" + row.getRowNum() + " Stun:"
                            + cell.getColumnIndex() + " Hata Nedeni: Veri tipi yaz deil");
                }
                e.setExpenseName(cell.getStringCellValue());
            } else if (cell.getColumnIndex() == 3) {
                if (cell.getCellType() != Cell.CELL_TYPE_STRING) {
                    throw new ExpenseExcelFormatException("Hatal veri! Satr:" + row.getRowNum() + " Stun:"
                            + cell.getColumnIndex() + " Hata Nedeni: Veri tipi yaz deil");
                }
                e.setPaymentMethod(cell.getStringCellValue());
            } else if (cell.getColumnIndex() == 4) {
                if (cell.getCellType() != Cell.CELL_TYPE_STRING) {
                    throw new ExpenseExcelFormatException("Hatal veri! Satr:" + row.getRowNum() + " Stun:"
                            + cell.getColumnIndex() + " Hata Nedeni: Veri tipi yaz deil");
                }
                e.setCurrency(cell.getStringCellValue());
            } else if (cell.getColumnIndex() == 5) {
                if (cell.getCellType() != Cell.CELL_TYPE_NUMERIC) {
                    throw new ExpenseExcelFormatException("Hatal veri! Satr:" + row.getRowNum() + " Stun:"
                            + cell.getColumnIndex() + " Hata Nedeni: Veri tipi nmerik deil");
                }
                e.setNetAmount(BigDecimal.valueOf(cell.getNumericCellValue()));
            } else if (cell.getColumnIndex() == 6) {
                if (cell.getCellType() != Cell.CELL_TYPE_STRING) {
                    throw new ExpenseExcelFormatException("Hatal veri! Satr:" + row.getRowNum() + " Stun:"
                            + cell.getColumnIndex() + " Hata Nedeni: Veri tipi yaz deil");
                }
                e.setRestaurant(cell.getStringCellValue());
            } else if (cell.getColumnIndex() == 7) {
                if (cell.getCellType() != Cell.CELL_TYPE_NUMERIC) {
                    throw new ExpenseExcelFormatException("Hatal veri! Satr:" + row.getRowNum() + " Stun:"
                            + cell.getColumnIndex() + " Hata Nedeni: Veri tipi nmerik deil");
                }
                e.setDocumentNumber(Integer.valueOf((int) cell.getNumericCellValue()));
            }
        }
        expenses.add(e);
    }

    if (wb != null)
        wb.close();

    if (fis != null)
        fis.close();

    return expenses;
}

From source file:org.nekorp.workflow.desktop.control.imp.ProgramacionServicioWizardImp.java

License:Apache License

@Override
public void importarArchivo(File archivo) {
    programacionMetadata.setDetalles("");
    OPCPackage pkg = null;/*from w  w w .  ja va  2 s . c  o  m*/
    try {
        addDetail("Leyendo archivo: " + archivo.getCanonicalPath());
        pkg = OPCPackage.open(archivo);
        XSSFWorkbook wb = new XSSFWorkbook(pkg);
        //Workbook wb = WorkbookFactory.create(archivo);
        Sheet sheet = wb.getSheetAt(0);
        //Row encabezado = sheet.getRow(0);
        List<String> nombresServicios = null;
        boolean inicio = true;
        nuevosAutos = new LinkedList<>();
        nuevosServicio = new LinkedList<>();
        for (Row row : sheet) {
            if (inicio) {
                nombresServicios = procesarEncabezado(row);
                inicio = false;
            } else {
                if (row.getPhysicalNumberOfCells() == nombresServicios.size()) {
                    Auto autoCargado = new Auto();
                    cargarDatosAuto(row, autoCargado);
                    autoBridge.load(autoCargado, servicio.getAuto());
                    Servicio nuevoServicio = new Servicio();
                    if (buscarNuevoServicio(row, nuevoServicio, nombresServicios, rangoNuevo)) {
                        //se intentan cargar
                        servicioBridge.load(nuevoServicio, servicio);
                        addDetail("Se encontro un nuevo servicio para el auto con numero de serie: "
                                + autoCargado.getNumeroSerie());
                        addDetail("Descripcin del servicio encontrado:\n" + nuevoServicio.getDescripcion());
                        if (validacionGeneralDatosAuto.isValido()) {
                            nuevosAutos.add(autoCargado);
                            nuevosServicio.add(nuevoServicio);
                        } else {
                            addDetail(
                                    "los datos del nuevo servicio tienen los siguientes errores y no se dara de alta:");
                            addDetail(validacionDatosAuto.concatenaErrores());
                        }
                    }
                    List<AlertaServicio> nuevasAlertas = buscarAlertas(row, nombresServicios, rangoAlerta);
                    for (AlertaServicio x : nuevasAlertas) {
                        x.setMarcaAuto(autoCargado.getMarca());
                        x.setPlacasAuto(autoCargado.getPlacas());
                        x.setTipoAuto(autoCargado.getTipo());
                        x.setNombreCliente(servicio.getCliente().getNombre());
                        addDetail("Se encontro un servicio proximo para el auto con numero de serie: "
                                + autoCargado.getNumeroSerie());
                        addDetail("Descripcin de la nueva alerta:\n" + x.getDescripcionServicio());
                        alertas.add(x);
                    }
                    AlertaVerificacion nuevaAlerta = buscarAlertasVerificacion(autoCargado.getPlacas());
                    if (nuevaAlerta != null) {
                        addDetail("Se encontro un auto que pudiera necesitar verificacin: "
                                + autoCargado.getNumeroSerie());
                        addDetail(
                                "placas: " + nuevaAlerta.getPlacas() + " periodo: " + nuevaAlerta.getPeriodo());
                        alertasVerificacion.add(nuevaAlerta);
                    }
                }
            }
        }
        if (nuevosServicio.size() > 0) {
            if (nuevosServicio.size() == 1) {
                addDetail("Se tiene listo para crear un nuevo servicio");
            } else {
                addDetail("Se tienen listos para crear " + nuevosServicio.size() + " servicios nuevos");
            }
        } else {
            addDetail("No se encontro ningun nuevo servicio");
        }
        int cantidadAlertas = alertas.size() + alertasVerificacion.size();
        if (cantidadAlertas > 0) {
            if (cantidadAlertas == 1) {
                addDetail("Se tiene lista para enviar una nueva alerta");
            } else {
                addDetail("Se tienen listas para enviar " + cantidadAlertas + " alertas");
            }
        } else {
            addDetail("No se encontro ninguna alerta");
        }
        if (nuevosServicio.size() > 0 || cantidadAlertas > 0) {
            validacionGeneralProgramacion.setValido(true);
        } else {
            validacionGeneralProgramacion.setValido(false);
        }
    } catch (IOException | InvalidFormatException | IllegalArgumentException ex) {
        ProgramacionServicioWizardImp.LOGGER.error("exploto!!!", ex);
        addDetail("ocurrio un error inesperado al leer el archivo." + ex.getMessage());
    } finally {
        if (pkg != null) {
            try {
                pkg.close();
            } catch (IOException ex) {
                //ProgramacionServicioWizardImp.LOGGER.error("exploto!!!", ex);
            }
        }
    }
}

From source file:org.nuxeo.ecm.core.convert.plugins.text.extractors.XLX2TextConverter.java

License:Apache License

@Override
public BlobHolder convert(BlobHolder blobHolder, Map<String, Serializable> parameters)
        throws ConversionException {

    InputStream stream = null;/*from  w ww  .  j av a2s .  c om*/
    StringBuffer sb = new StringBuffer();

    try {
        Blob blob = blobHolder.getBlob();

        if (blob.getLength() > maxSize4POI) {
            return runFallBackConverter(blobHolder, "xl/");
        }

        stream = blob.getStream();

        OPCPackage p = OPCPackage.open(stream);
        XSSFWorkbook workbook = new XSSFWorkbook(p);
        for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
            XSSFSheet sheet = workbook.getSheetAt(i);
            Iterator<Row> rows = sheet.rowIterator();
            while (rows.hasNext()) {
                XSSFRow row = (XSSFRow) rows.next();
                Iterator<Cell> cells = row.cellIterator();
                while (cells.hasNext()) {
                    XSSFCell cell = (XSSFCell) cells.next();
                    appendTextFromCell(cell, sb);
                }
                sb.append(ROW_SEP);
            }
        }
        return new SimpleCachableBlobHolder(Blobs.createBlob(sb.toString()));
    } catch (IOException | OpenXML4JException e) {
        throw new ConversionException("Error during XLX2Text conversion", e);
    } finally {
        if (stream != null) {
            try {
                stream.close();
            } catch (IOException e) {
                log.error("Error while closing Blob stream", e);
            }
        }
    }
}

From source file:org.olat.search.service.document.file.ExcelOOXMLDocument.java

License:Apache License

private void extractContent(final StringBuilder buffy, final XSSFWorkbook document) {
    for (int i = 0; i < document.getNumberOfSheets(); i++) {
        final XSSFSheet sheet = document.getSheetAt(i);
        buffy.append(document.getSheetName(i)).append(' ');

        // Header(s), if present
        extractHeaderFooter(buffy, sheet.getFirstHeader());
        extractHeaderFooter(buffy, sheet.getOddHeader());
        extractHeaderFooter(buffy, sheet.getEvenHeader());

        // Rows and cells
        for (final Object rawR : sheet) {
            final Row row = (Row) rawR;
            for (final Iterator<Cell> ri = row.cellIterator(); ri.hasNext();) {
                final Cell cell = ri.next();

                if (cell.getCellType() == Cell.CELL_TYPE_FORMULA
                        || cell.getCellType() == Cell.CELL_TYPE_STRING) {
                    buffy.append(cell.getRichStringCellValue().getString()).append(' ');
                } else {
                    final XSSFCell xc = (XSSFCell) cell;
                    final String rawValue = xc.getRawValue();
                    if (rawValue != null) {
                        buffy.append(rawValue).append(' ');
                    }/* w  ww .  ja  v  a 2s. c  om*/

                }

                // Output the comment in the same cell as the content
                final Comment comment = cell.getCellComment();
                if (comment != null) {
                    buffy.append(comment.getString().getString()).append(' ');
                }
            }
        }

        // Finally footer(s), if present
        extractHeaderFooter(buffy, sheet.getFirstFooter());
        extractHeaderFooter(buffy, sheet.getOddFooter());
        extractHeaderFooter(buffy, sheet.getEvenFooter());
    }
}

From source file:org.opencities.berlin.uploaddata.service.Worker.java

/**
 * loop through all Cells and rows. Firstly, add correct keys to strings.
 * Secondly, parse corresponding value into correct json and add this
 * dataset to ckan via middleware.//w w w . j  a  v a 2  s.  co  m
 * 
 * @param args
 * @throws Exception
 */
@SuppressWarnings("rawtypes")
public String readXlsx() {
    String errormessage = "";

    CKANGateway gw = new CKANGateway(ckan, key);
    HashMap<String, String> map = new HashMap<String, String>();
    ArrayList<String> strings = new ArrayList<String>();
    XSSFWorkbook workBook = null;
    try {
        workBook = new XSSFWorkbook(uploadFolder + "file.xlsx");
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    int counter = 0;
    XSSFSheet sheet = workBook.getSheetAt(0);
    for (Row row : sheet) {
        for (Cell cell : row) {
            switch (cell.getCellType()) {
            case Cell.CELL_TYPE_STRING:
                String value = cell.getRichStringCellValue().getString();
                // first row, add value to strings
                if (counter == 0) {
                    if (!value.startsWith("resources:") && !value.startsWith("extras:"))
                        map.put(value, null);

                    strings.add(value);
                    break;
                }
                if (strings.get(cell.getColumnIndex()).equalsIgnoreCase("tags")
                        || strings.get(cell.getColumnIndex()).equalsIgnoreCase("groups")) {
                    String[] tmp = value.split(",");
                    String out = buildString(tmp);
                    map.put(strings.get(cell.getColumnIndex()), out);
                } else if (strings.get(cell.getColumnIndex()).startsWith("resources:")) {
                    String[] tmp = strings.get(cell.getColumnIndex()).split(":");
                    parseResource(tmp[1], value);
                } else if (strings.get(cell.getColumnIndex()).startsWith("extras:")) {
                    String[] tmp = strings.get(cell.getColumnIndex()).split(":");
                    parseExtras(tmp[1], value);
                } else {
                    map.put(strings.get(cell.getColumnIndex()), "\"" + value + "\"");
                }
                break;
            case Cell.CELL_TYPE_NUMERIC:
                if (DateUtil.isCellDateFormatted(cell)) {
                    // is a date;
                    map = handleDate(map, strings, cell);
                } else {
                    // is a number;
                    map = handleNumber(map, strings, cell);
                }
                break;
            default:
                break;
            }
        }
        // finish extras and resources
        finishParseResource();
        finishParseExtras();

        map = checkEmptyValues(map);
        map = toLowerCase(map);
        // add resources and extras to map
        map.put("resources", resourceString);
        map.put("extras", extrasString);
        if (counter >= 1) {
            // add dataset to CKAN via middleware
            HashMap<String, HashMap> out = gw.createMetaDataSet(map);
            if (out == null)
                errormessage += String.valueOf(counter) + ",";
        }
        ++counter;
        resourceString = resetResourceString();
        extrasString = resetExtrasString();
    }

    if (errormessage.equalsIgnoreCase(""))
        return errormessage;
    else
        return errormessage.substring(0, errormessage.length() - 1);
}

From source file:org.openepics.discs.ccdb.core.dl.common.ExcelImportFileReader.java

License:Open Source License

/**
 * This method returns the contents of the first worksheet found in the
 * Excel workbook file./*from  w ww .  j a  v  a 2s  .  c om*/
 *
 * @param inputStream
 *              the Excel file to parse. Only Excel file version &gt;=12.0
 *              supported (.xslx).
 * @param dataStartIndex
 *              the index of the row where to start parsing the import data.
 * @param dataRowLength
 *              the length of each row if it contains all the data. This length is usually defined by the Excel
 *              template.
 * @return Only the lines from the first worksheet that contain a string
 *         value. Lines with the empty first cell are not part of the return
 *         set. Each row is represented as a pair of the row number and a list of columns.
 */
public static List<Pair<Integer, List<String>>> importExcelFile(InputStream inputStream, int dataStartIndex,
        final int dataRowLength) {
    final List<Pair<Integer, List<String>>> result = new ArrayList<>();

    try {
        final XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
        final XSSFSheet sheet = workbook.getSheetAt(0);

        for (Row excelRow : sheet) {
            if (excelRow.getRowNum() < dataStartIndex) {
                continue;
            }
            final String firstColumnValue = Strings
                    .emptyToNull(ExcelCell.asStringOrNull(excelRow.getCell(0), workbook));
            if (firstColumnValue != null && !firstColumnValue.trim().isEmpty()) {
                final List<String> row = new ArrayList<>();
                final int rowNumber = excelRow.getRowNum() + 1;
                final int lastCellIndex = dataRowLength > excelRow.getLastCellNum() ? dataRowLength
                        : excelRow.getLastCellNum();
                for (int i = 0; i < lastCellIndex; i++) {
                    row.add(ExcelCell.asStringOrNull(excelRow.getCell(i), workbook));
                }
                result.add(new ImmutablePair<Integer, List<String>>(rowNumber, row));
            }
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    return result;
}

From source file:org.openepics.names.ui.devices.ExcelImport.java

License:Open Source License

/**
 * Parses the input stream read from an Excel file, creating devices in the database. If the device already exists,
 * it's silently ignored.//ww w  . ja  va  2  s . c o  m
 *
 * @param input the input stream
 * @return an ExcelImportResult object reporting the outcome of the import operation
 */
public ExcelImportResult parseDeviceImportFile(InputStream input) {
    init();

    try {
        final XSSFWorkbook workbook = new XSSFWorkbook(input);
        final XSSFSheet sheet = workbook.getSheetAt(0);
        for (Row row : sheet) {
            if (row.getRowNum() > 0) {
                if (row.getLastCellNum() < 5) {
                    return new ColumnCountFailureExcelImportResult();
                } else {
                    final String superSection = ExcelCell.asString(row.getCell(0));
                    final String section = As.notNull(ExcelCell.asString(row.getCell(1)));
                    final String subsection = As.notNull(ExcelCell.asString(row.getCell(2)));
                    final String discipline = As.notNull(ExcelCell.asString(row.getCell(3)));
                    final String deviceType = As.notNull(ExcelCell.asString(row.getCell(4)));
                    final @Nullable String index = ExcelCell.asString(row.getCell(5));
                    final @Nullable String description = ExcelCell.asString(row.getCell(6));
                    final ExcelImportResult addDeviceNameResult = addDeviceName(superSection, section,
                            subsection, discipline, deviceType, index, description, row.getRowNum());
                    if (addDeviceNameResult instanceof FailureExcelImportResult) {
                        return addDeviceNameResult;
                    }
                }
            }
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    namePartService.batchAddDevices(newDevices);
    return new SuccessExcelImportResult();
}

From source file:org.openstreetmap.josm.plugins.msf1.XLSX_Reader.java

public static void getIndexes(String arg) throws IOException {
    try {/*from   w w w . j  ava 2  s  .com*/

        ExcelFileToRead = new FileInputStream(arg);
        XSSFWorkbook wb = new XSSFWorkbook(ExcelFileToRead);
        XSSFCell cell;
        XSSFSheet sheet = wb.getSheetAt(0);
        Iterator cells = sheet.getRow(0).cellIterator();

        while (cells.hasNext()) {
            cell = (XSSFCell) cells.next();
            if (cell != null) {
                if (cell.getCellType() == XSSFCell.CELL_TYPE_STRING) {
                    if (cell.getStringCellValue().equalsIgnoreCase("_Location_Latitude")) {
                        lat_index = cell.getColumnIndex();
                    }
                    if (cell.getStringCellValue().equalsIgnoreCase("_LOCATION_longitude")) {
                        lon_index = cell.getColumnIndex();
                    }
                    if (cell.getStringCellValue().equalsIgnoreCase("Village_name")) {
                        villageName_index = cell.getColumnIndex();
                    }
                    if (cell.getStringCellValue().equalsIgnoreCase("Alt_village_name")) {
                        altVillageName_index = cell.getColumnIndex();
                    }
                    if (cell.getStringCellValue().equalsIgnoreCase("HANDPUMP_WORKING")) {
                        handpump_condition_index = cell.getColumnIndex();
                    }
                    if (cell.getStringCellValue().equalsIgnoreCase("WATERPOINT_NAME")) {
                        waterPointName_index = cell.getColumnIndex();
                    }
                    if (cell.getStringCellValue().equalsIgnoreCase("BOREHOLE_PROTECTED")) {
                        borehole_access_index = cell.getColumnIndex();
                    }
                }

            }

        }

        lon_array = new String[sheet.getPhysicalNumberOfRows()];

        for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
            Row row = sheet.getRow(i);

            if (row.getCell(lon_index) == null
                    || row.getCell(lon_index).getCellType() == Cell.CELL_TYPE_BLANK) {
                i++;
            } else if (row.getCell(lon_index).getCellType() == XSSFCell.CELL_TYPE_NUMERIC
                    || row.getCell(lon_index).getCellType() == XSSFCell.CELL_TYPE_STRING) {
                String var = row.getCell(lon_index).toString();
                lon_array[i] = var;
                // System.out.println(var);
            } else {
                lon_array[i] = "null";

            }
        }

        lat_array = new String[sheet.getPhysicalNumberOfRows()];
        for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
            Row row = sheet.getRow(i);
            if (row.getCell(lat_index) == null
                    || row.getCell(lat_index).getCellType() == Cell.CELL_TYPE_BLANK) {
                i++;
            } else if (row.getCell(lat_index).getCellType() == XSSFCell.CELL_TYPE_NUMERIC
                    || row.getCell(lat_index).getCellType() == XSSFCell.CELL_TYPE_STRING) {
                String var = row.getCell(lat_index).toString();
                lat_array[i] = var;
                // System.out.println(var);
            } else {
                lat_array[i] = "null";

            }
        }

        villageName_array = new String[sheet.getPhysicalNumberOfRows()];
        for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
            Row row = sheet.getRow(i);
            if (row.getCell(villageName_index) == null
                    || row.getCell(villageName_index).getCellType() == Cell.CELL_TYPE_BLANK) {
                i++;
            } else if (row.getCell(villageName_index).getCellType() == XSSFCell.CELL_TYPE_NUMERIC
                    || row.getCell(villageName_index).getCellType() == XSSFCell.CELL_TYPE_STRING) {
                String var = row.getCell(villageName_index).toString();
                villageName_array[i] = var;
                //  System.out.println(var);
            } else {
                villageName_array[i] = "null";

            }

        }

        altVilageName_array = new String[sheet.getPhysicalNumberOfRows()];
        for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
            Row row = sheet.getRow(i);
            if (row.getCell(altVillageName_index) == null
                    || row.getCell(altVillageName_index).getCellType() == Cell.CELL_TYPE_BLANK) {
                i++;
            } else if (row.getCell(altVillageName_index).getCellType() == XSSFCell.CELL_TYPE_NUMERIC
                    || row.getCell(altVillageName_index).getCellType() == XSSFCell.CELL_TYPE_STRING) {
                String var = row.getCell(altVillageName_index).toString();
                altVilageName_array[i] = var;
                //  System.out.println(var);
            } else {
                altVilageName_array[i] = "null";

            }

        }

        borehole_access_array = new String[sheet.getPhysicalNumberOfRows()];
        for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
            Row row = sheet.getRow(i);
            if (row.getCell(borehole_access_index) == null
                    || row.getCell(borehole_access_index).getCellType() == Cell.CELL_TYPE_BLANK) {
                i++;
            } else if (row.getCell(borehole_access_index).getCellType() == XSSFCell.CELL_TYPE_NUMERIC
                    || row.getCell(borehole_access_index).getCellType() == XSSFCell.CELL_TYPE_STRING) {
                String var = row.getCell(borehole_access_index).toString();
                borehole_access_array[i] = var;
                // System.out.println(var);
            } else {
                borehole_access_array[i] = "null";

            }

        }
        handpump_condition_array = new String[sheet.getPhysicalNumberOfRows()];
        for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
            Row row = sheet.getRow(i);
            if (row.getCell(handpump_condition_index) == null
                    || row.getCell(handpump_condition_index).getCellType() == Cell.CELL_TYPE_BLANK) {
                i++;
            } else if (row.getCell(handpump_condition_index).getCellType() == XSSFCell.CELL_TYPE_NUMERIC
                    || row.getCell(handpump_condition_index).getCellType() == XSSFCell.CELL_TYPE_STRING) {
                String var = row.getCell(handpump_condition_index).toString();
                handpump_condition_array[i] = var;
                //System.out.println(var);
            } else {
                handpump_condition_array[i] = "null";

            }

        }

        waterPointName_array = new String[sheet.getPhysicalNumberOfRows()];
        for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
            Row row = sheet.getRow(i);
            if (row.getCell(waterPointName_index) == null
                    || row.getCell(waterPointName_index).getCellType() == Cell.CELL_TYPE_BLANK) {
                i++;
            } else if (row.getCell(waterPointName_index).getCellType() == XSSFCell.CELL_TYPE_NUMERIC
                    || row.getCell(waterPointName_index).getCellType() == XSSFCell.CELL_TYPE_STRING) {
                String var = row.getCell(waterPointName_index).toString();
                waterPointName_array[i] = var;
                // System.out.println(var);
            } else {
                waterPointName_array[i] = "null";

            }

        }

        //    public static String[] getLon_array() {
        //        return lon_array;
        //    }
        //    
        //    public static String[] getLat_array() {
        //        return lat_array;
        //    }
        //    public static String[] getVillageName_array() {
        //        return  villageName_array;
        //    } 
        //    public static String[] getAltVillageName_array() {
        //        return altVilageName_array;
        //    }
        //    public static String[] getBoreholeAccess_array() {
        //        return borehole_access_array;
        //    }
        //    public static String[] getHandPumpCondition_array() {
        //        return handpump_condition_array;
        //    }
        //    public static String[] getWaterPoint_array() {
        //        return waterPointName_array;
        //    }
        wb.close();
    } catch (IOException e) {
    }
}