Announcement Announcement Module
No announcement yet.
how to read data from excel file using spring batch Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to read data from excel file using spring batch

    Currently we are reading records from csv text file using
    org.springframework.batch.item.file.transform.Deli mitedLineTokenizer.
    Now we are shifting to XLS format from csv format.
    does spring batch having any deafult supporting transformer available to read content from excel file. if not can I have any suggestions.
    Please help.

  • #2
    Unfortunately, the farthest Spring Batch goes is supporting Excel generated CSVs.


    • #3
      Try here: Open office also has some Java APIs.


      • #4
        How to handle the event API of POI/Integration with Spring Batch


        I'm using POI's HSSFListener to read in an Excel file (sort of like SAX for Excel ) and it works fine. Now, I'm trying to figure out a way of integrating this with Spring Batch - I basically don't need the ItemReader /FieldSet stuff at all as I already have the values in their correct format e.g. date, double, string etc

        Now- I'm trying to figure out how to implement this that I can plug it into the batch architecture -but I'm not sure how. The main problem is that the POI events would actually drive the Items - i.e. there are no call - but I'd like somehow to use as much of the batch infrastructure as possible.
        One other alternative it to read the entire Excel into memory using POI and let an ItemReader read the stored rows - but that is not a very scalable solution.

        Any ideas welcome.


        • #5
          The event-based model isn't a good fit for batch processing, as you already noticed (that's why we use StaX in the XML reader). You would be better off going with the Worksheet/Row API in POI. Incidentally, someone else was asking about this the other day and had some code to contribute, so we might see something in the framework soon.


          • #6
            how to read data from excel file using spring batch

            Is reading of excel sheet feature included now in spring batch?


            • #7
              Originally posted by Parths View Post
              Is reading of excel sheet feature included now in spring batch?
              No. CSV is supported but not Excel native worksheets.


              • #8
                Thanks jmoore.


                • #9

                  I am trying to upload a excel file if it as 100000 of rows then a get the java heap space error

                  how will resolve this

                  this is my code.

                  FileInputStream myInput = new FileInputStream(fileName);
                  if (extention.equalsIgnoreCase("xlsx"))
                  XSSFWorkbook wb = new XSSFWorkbook(myInput);
                  XSSFSheet sheet = wb.getSheetAt(0);
                  ExcelServiceImpl.saveExceldataxlxsdata(sheet,httpS ervletRequest);
                  else if (extention.equalsIgnoreCase("xls"))
                  POIFSFileSystem fileSystem = new POIFSFileSystem(myInput);
                  HSSFWorkbook myWorkBook = new HSSFWorkbook(fileSystem);
                  HSSFSheet mySheet = myWorkBook.getSheetAt(0);
                  ExcelServiceImpl.saveExcelsdata(mySheet,httpServle tRequest);

                  please help me.