0

I am trying to write data into a excel sheet using JAVA, I am able to achieve it when the excel file is closed.

But, When I try to write data when the file is open, I get java.io.FileNotFoundException .

Is there a way to overcome this? If not, can you please explain me why??

  • More information is needed. Where is the exact location of the Excel that you want to write to. Show the exact code where you open the Excel file. Are you using Apache POI ? – rjdkolb Jan 18 '16 at 09:51
  • 1
    Show us the code. which library's you are using, line where the error occurs etc. Your question is incomplete. – user5612655 Jan 18 '16 at 09:51
  • 1
    Sounds like this one: http://stackoverflow.com/questions/12938509/poi-cannot-write-to-file-while-it-is-opened-in-excel – Alex Jan 18 '16 at 09:53

1 Answers1

0

Unfortunatly I believe there is nothing you can do about it as I do not think that Java supports reading files that are already opened by other applications (I am guessing that you are getting "Permission denied" in the exception).

CrookedBadge
  • 130
  • 9
  • Yes, it is similar to a Permission denied error... But is there a way to overcome this? java.io.FileNotFoundException: D:\data\kishore\Edit_punches_output.xls (The process cannot access the file because it is being used by another process) – Kishore Jagadeesan Jan 18 '16 at 11:00
  • I believe there is not, I'm a little uncertain where the denial of permission is happening too. It might be on the JVM level or it might be on the OS level (I believe that windows for instance does not like when a file is opened for editing by several applications). There might be a way to go around it if you would want to just read the file, but not write to it. – CrookedBadge Jan 18 '16 at 12:33