By Rengasami Ramanujam

2012-04-20 15:09:10 8 Comments

I know that we can use Apache POI to parse an Excel file and get data. But I heard of a strange thing that excel file can be passed in a similar way we parse CSV (Like just read the file from file Stream and separate each column value with a "comma" separator). When we parse Excel we have to use tab as a delimiter. Is it possible? If yes then why Apache has come up with such a complicated framework. I am puzzled. Can someone help me?


@Baisakha Chauhan 2018-03-08 07:46:47

InputStream is = new FileInputStream(new File(filepath));
        StreamingReader reader=null;
        try {
            reader = StreamingReader.builder()
        } catch (Exception e1) {
            // TODO Auto-generated catch block
        //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 


@Shahrukh A. 2014-05-03 21:08:14

i tried to read/write excel file without using any external JAR like POI or any other. I am able to write file as xls format. Here is my Code

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

Reading File here is my code for reading

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) {
            } catch (IOException e) {
            } finally {
                if(reader != null) {
                    try {
                    } catch (IOException e) {

@maksimov 2016-02-18 20:09:13

This is not an Excel format per-se, what you're writing/reading is a tab-delimited text file. It only so happens that Excel opens CSV or TSV the same way it opens files of its own proprietary format.

@maksimov 2012-04-20 15:19:27

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

As a side note, on the path to become a good developer you will need to learn to do a bit of your own research before looking for help. Get your hands dirty is the best way to learn things.

@Rengasami Ramanujam 2012-04-20 15:26:54

Hey Thanks man, I tried my level best with getting my hands dirty. All the ways said that I cannot do tab delimited parsing.But rather the person who insisted this is damn sure on what he is saying. Thats why I sought your help. :)

@maksimov 2012-04-20 15:30:23

Well sometimes people have wrong information and sometimes these people are stubborn. To you "tab delimited" should mean a "text file". Text files open in Notepad. Try opening an Excel file in Notepad and see what happens.

@Rengasami Ramanujam 2012-04-20 15:32:28

yeap thats right. Thanks for your help dude :)

@Michael Berry 2012-04-20 15:14:29

You've probably confused what you've heard, or the person telling you was confused.

Some parts of Excel files can be stored (somewhat) as CSV files as the tabular data structure fits well within a CSV file format. However, if you save in CSV format then you just get plain text in each cell - you lose all formatting information, any graphs, multiple worksheets and so on.

The native XLS excel format is what Apache POI works with, and so can handle everything in excel, not just restrictive plain text in certain cells. CSV files have their uses but they're definitely not a straight replacement for normal Excel files.

@Rengasami Ramanujam 2012-04-20 15:18:19

If I create office 2003 Microsoft Excel file with 4x4 cells which contains just textual data. Then if I read the file in input stream and try to us "\t" as a separator. Then will it work without Apache POI?

@Michael Berry 2012-04-20 15:20:14

Not if you use the XLS format, only if you use CSV.

@Rengasami Ramanujam 2012-04-20 15:31:58

Got it! Thank you :)

Related Questions

Sponsored Content

23 Answered Questions

[SOLVED] What exactly is Apache Camel?

4 Answered Questions

[SOLVED] Error While Reading Large Excel Files (xlsx) Via Apache POI

1 Answered Questions

5 Answered Questions

1 Answered Questions

[SOLVED] Number as it is from excel file using Apache POI

1 Answered Questions

[SOLVED] Apache POI - reading modifies excel file

  • 2016-10-07 14:58:26
  • MJar
  • 648 View
  • 4 Score
  • 1 Answer
  • Tags:   java apache-poi

2 Answered Questions

[SOLVED] Is there any limitation on size of excel file that Apache POI can handle?

1 Answered Questions

[SOLVED] Can Apache POI convert an Excel file to CSV without parsing?

2 Answered Questions

storing the output of java program in an excel sheet through Apachae POI

0 Answered Questions

Apache POI Excel getDateCellValue() wrong year

Sponsored Content