Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Like DaDaDom said Apache POI is what you are looking for. You can download it from <a href="http://poi.apache.org/download.html">this page</a>. Mind that POI project is not fully independent and you may need to download some extra libraries. Follow the instructions on Apache POI website. This is how you use it:</p> <pre><code>InputStream myxls = new FileInputStream("workbook.xls")); HSSFWorkbook wb = new HSSFWorkbook(myxls); // for *.xlsx use XSSFWorkbook </code></pre> <p>If it's a new file you might need to create sheet before proceeding, but in this case the files are already created.</p> <pre><code>HSSFSheet sheet = wb.getSheetAt(0); // first sheet HSSFRow row = sheet.getRow(0); // first row HSSFCell cell = row.getCell((short)0); // first cell </code></pre> <p>To get value from the cell use:</p> <pre><code>String value = cell.getStringCellValue(); </code></pre> <p>However if the type stored in cell is numeric you would get an error. In case of numbers use:</p> <pre><code>Int value = cell.getCellValue(); </code></pre> <p>This is a method I wrote to deal with different cell data types:</p> <pre><code>public String getValue(int x, int y){ Row row = this.activeSheet.getRow(y); if(row==null) return ""; Cell cell = row.getCell(x); if(cell==null) return ""; int type = cell.getCellType(); switch(type){ case 0: return cell.getNumericCellValue() + ""; case 1: return cell.getStringCellValue(); case 2: return cell.getCellFormula(); case 3: return ""; case 4: return cell.getBooleanCellValue() + ""; case 5: return cell.getErrorCellValue() + ""; default: return ""; } } </code></pre> <p>I hope this quick introduction into Apache POI will help you with your project :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload