title: Upload and read the excel file and insert the data in Database using groovy grails
body: <p>Here is the GSP code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta name="layout" content="main"&gt;
          &lt;title&gt;Upload New Document&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;div class="nav" role="navigation"&gt;
              &lt;ul&gt;&lt;li&gt;&lt;g:link class="list" action="list"&gt;Document List&lt;/g:link&gt;&lt;/li&gt;&lt;/ul&gt;
              &lt;/div&gt;
              &lt;div class="content scaffold-create" role="main"&gt;
                  &lt;h1&gt;Upload New Document&lt;/h1&gt;
              &lt;g:if test="${flash.message}"&gt;&lt;div class="message" role="status"&gt;${flash.message}&lt;/div&gt;&lt;/g:if&gt;
              &lt;g:uploadForm action="upload"&gt;
                      &lt;fieldset class="form"&gt;
          &lt;input type="file" name="file" /&gt;
                      &lt;/fieldset&gt;
                      &lt;fieldset class="buttons"&gt;
                              &lt;g:submitButton name="upload" class="save" value="Upload" /&gt;
                      &lt;/fieldset&gt;
              &lt;/g:uploadForm&gt;
          &lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here is the  Controller:</p>
  
  <pre><code>def upload() {
  
          def file = request.getFile('file')
  
          // inp = new FileInputStream(uploadedFile);
  
          XSSFWorkbook book = new XSSFWorkbook(file);
          XSSFSheet[] sheets = book.sheets;
          for (XSSFSheet sheet : sheets)
          {
              println("\nSHEET NAME:"+sheet.getSheetName()+"\n");
              sheet.each { row -&gt;
                  Iterator cellIterator = row.cellIterator();
                  while(cellIterator.hasNext())
                  {
                      XSSFCell cell = cellIterator.next();
                      print(getCellValue(cell)+" ");
                  }
                  println();
              }
          }
          if(file.empty) {
              flash.message = "File cannot be empty"
          } else {
              def documentInstance = new Document()
              documentInstance.filename = file.originalFilename
              documentInstance.filedata = file.getBytes()
              documentInstance.save()
          }
          redirect (action:'list')
      }
  </code></pre>
  
  <p>I am getting the spring based exception </p>
  
  <pre><code>Could not find matching constructor for: org.apache.poi.xssf.usermodel.XSSFWorkbook(org.springframework.web.multipart.commons.CommonsMultipartFile)
  </code></pre>