2

I need to add a sheet to an existing excel file, but I don't know how to make the file im accessing r/w.

I read a large excel sheet and I simplify the data in the sheet I generate.

On linux, the program works perfectly, and adds a sheet to the excel file I need. On Windows, the program crashes because I suspect it does not have write permissions for the file which is downloaded by the user from the internet.

My question is how can I let Java write back a new sheet to the excel file I have read?

Allen
  • 350
  • 2
  • 13

2 Answers2

0

It's pretty straight forward.

1) Create a workbook from an input streaam.

2) Modify the workbook however you like, including creating a new sheet.

3) Write the workbook to an output stream.

There already is a very good example on Stack Overflow. See Edit existing excel files using jxl api / Apache POI

I found this example quite quickly with Google, so next time you have a question I suggest you search a little more carefully before asking a question.

Community
  • 1
  • 1
Howard Schutzman
  • 2,115
  • 1
  • 15
  • 8
0

It turns out I was using invalid characters in the file name, thus it wasn't working on Windows but was perfectly fine on linux.

Allen
  • 350
  • 2
  • 13