1

I'm using JExcelApi v2.6.12 jar file. http://www.andykhan.com/jexcelapi/download.html .

I have a xml file like below image :

enter image description here

now,I would like to get all row from this file:

I'm following this answer How to read data from XLS (Excel) file [Java, Android]

but it doesn't works and my result always returns "Data not found..!"

my codes:

private void test(){
    String iconsStoragePath = Environment.getExternalStorageDirectory() + "/SmsBaz";
    File sdIconStorageDir = new File(iconsStoragePath);

        String filePath = sdIconStorageDir.toString() +"/m.xls";

    try {
        List<String> resultSet =  read("id",filePath);
        Log.e("size","=>"+resultSet.get(0));
    } catch (IOException e) {
        e.printStackTrace();
    }
}

public List<String> read(String key,String inputFile) throws IOException {
    List<String> resultSet = new ArrayList<String>();

    File inputWorkbook = new File(inputFile);
    if(inputWorkbook.exists()){
        Workbook w;
        try {
            w = Workbook.getWorkbook(inputWorkbook);
            // Get the first sheet
            Sheet sheet = w.getSheet(0);
            // Loop over column and lines
            for (int j = 0; j < sheet.getRows(); j++) {
                Cell cell = sheet.getCell(0, j);
                if(cell.getContents().equalsIgnoreCase(key)){
                    for (int i = 0; i < sheet.getColumns(); i++) {
                        Cell cel = sheet.getCell(i, j);
                        resultSet.add(cel.getContents());
                    }
               }
                continue;
            }
        } catch (BiffException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    else
    {
        resultSet.add("File not found..!");
    }
    if(resultSet.size()==0){
        resultSet.add("Data not found..!");
    }
    return resultSet;
}
4
  • it seems you are trying to read data from 2013 excel which is not supported by jexcel APIs read features at jexcelapi.sourceforge.net Commented Aug 9, 2015 at 2:43
  • Try Apache poi.apache.org Commented Aug 9, 2015 at 2:45
  • @ VD',thanks, plz give me an example. Commented Aug 9, 2015 at 3:48
  • i bet google can give a better example than me! Commented Aug 10, 2015 at 6:25

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.