Announcement Announcement Module
Collapse
No announcement yet.
how to read data from excel file using spring batch Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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.
    Thanks
    Raj.

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

    Comment


    • #3
      Try here: http://poi.apache.org/? Open office also has some Java APIs.

      Comment


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

        Hi,

        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 ItemReader.read() 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.

        Comment


        • #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.

          Comment


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

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

            Comment


            • #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.

              Comment


              • #8
                Thanks jmoore.

                Comment


                • #9
                  Hi,


                  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);
                  try{
                  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.

                  Comment

                  Working...
                  X