0

I developed a download functionality in a web application where a user can download selected records in excel file or in text file.

  • For download in excel I have used Apache POI and using SXSSFWorkbook class for writing.
  • For download in Text file I have used java IO.

Everything is working fine in windows (All browsers) but in IPAD (Safari) download in excel functionality is not opening, saying unable to read document (An error occurred while reading the file). However, text download is working fine.

I goggled and found it might be due to some encryption in the file. Then I have changed the file extension from "xls" to "xlsx". But still its not working.

Is there any limitation with APACHE POI API? Because, I am able to open a normal xls/xlsx file in IPAD but not the programmaticaly created once.

Setting mime mappings in web.xml -

<mime-mapping> 
    <extension> 
        xls 
    </extension> 
    <mime-type> 
        application/vnd.ms-excel
    </mime-type>
  </mime-mapping>
  <mime-mapping> 
    <extension> 
        xlsx
    </extension> 
    <mime-type> 
        application/vnd.ms-excel
    </mime-type>
  </mime-mapping>

Also, in weblogic config we have mimemappings.properties.

Saurabh
  • 2,384
  • 6
  • 37
  • 52
  • Do you have an app that can show you the xls/xlsx files? – Jens Jan 29 '15 at 08:41
  • Check whether mime type is set in HTTP headers for excel. also see http://stackoverflow.com/questions/974079/setting-mime-type-for-excel-document – sashwat Jan 29 '15 at 08:55
  • I am already setting mime mappings in web.xml. – Saurabh Jan 29 '15 at 11:42
  • @Jens, yes the app is Microsoft Excel. – Saurabh Jan 30 '15 at 13:11
  • did you find a solution for this? – Ostap Sep 04 '15 at 09:36
  • @Ostap, we have entered a mapping for xlsx in mimemapping.xml (Oracle\Middleware\user_projects\domains\base_domain\config\mimemappings.properties) as xlsx=application/vnd.ms-excel and now it is openning in Microsoft Excel application. – Saurabh Sep 07 '15 at 08:10
  • Thanks! I had a different problem in the end: Safari seems to have issues with inline-string inside xlsx. I fixed it by upgrading to POI 3.12 and using SXSSFWorkbook(XSSFWorkbook workbook, int rowAccessWindowSize, boolean compressTmpFiles, boolean useSharedStringsTable). Also, I had to specify the correct MIME type for xlsx. – Ostap Sep 08 '15 at 12:36

0 Answers0