Skip to content
Advertisement

How to copy excel sheet to the same worbook?

I’m trying to copy an existing excel sheet to the same workbook(it contains 3 sheets ) in java using Apache poi .

Here is what i did :

JavaScript

after running this code, the workbook contains always 3 sheets , the “copy_file” is not created, i’m not getting any errors or exceptions .

any idea ?

Advertisement

Answer

You need to open an output stream and write to the workbook. Make sure to close the workbook and the output stream after this write operation.

Demo:

JavaScript
Advertisement