Parsing Excel file without Apache POI

I know that we can use the Apache POI to parse an Excel file and get data. But I heard about the strange thing that the excel file can be transferred in the same way, we analyze the CSV (how easy it is to read the file from the Stream file and separate each column value with a comma delimiter). When we analyze Excel, we should use the tab as a separator. Is it possible? If so, why did Apache come up with such a complex structure. I am puzzled. Can anybody help me?

+3
source share
4 answers

CSV is a text format, so it can be parsed using delimiters. Old Excel is a binary and proprietary format, so it needs smart decoding. The new Excel format is compressed XML files, but you should also understand the structure of this document before it can be converted into something as simple as reading cells one by one. So the answer to your question is no, you will need to use the Apache POI, and also - there is nothing wrong with that.

As a side note, on the road to becoming a good developer, you need to learn how to do a little of your own research before seeking help. Dirty hands are the best way to find out.

+4
source

You are probably confusing what you heard, or the person telling you was embarrassed.

Excel () CSV, CSV. , CSV, - , , ..

XLS excel - , POI Apache, excel, . CSV , Excel.

+2

/ excel - JAR, POI . xls.

FileWriter fwriter = new FileWriter(file,true);
writer = new BufferedWriter(fwriter);
writer.newLine();
writer.write("a"    + "\t");
writer.write("b"    + "\t");
writer.write("c"    + "\t");
writer.write("d"    + "\t");
writer.write("e"    + "\t");
writer.write("f"    + "\t");

if(file != null) {
            BufferedReader reader = null;
            try {
                reader = new BufferedReader(new FileReader(file));
                String line;
                while((line = reader.readLine()) != null) {
                    String[] component = line.split("\\t");
                }
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                if(reader != null) {
                    try {
                        reader.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
0
InputStream is = new FileInputStream(new File(filepath));
        StreamingReader reader=null;
        try {
            reader = StreamingReader.builder()
                    .rowCacheSize(100)     
                    .bufferSize(4096)     
                    .sheetIndex(0)        
                    .read(is);
        } catch (Exception e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }finally{
            is.close();
        }
        //pass here to reader and itrate it 
          for (Row row : reader) {
            if (row.getRowNum()!=0){
                for (Cell cell : row) {
              // write ur logic to store ur value 
                }

            }
        }
0
source

All Articles