How to Copy the Sheet in Excel file


First of all I am very much thankful to Lakshay for doing such a great job. Really learned a lot.
My question is:
I am using Apache poi to retrieve the data from excel sheet. Here I have one testcase(Say Suppose ‘Create‘) with multiple rows of test data.When I execute this Testcase I am updating the Application number and result(pass/fail/skip) in the same sheet. But here I want to use the same data for another testcase(Say suppose Authorize)¬† with newly generated Application number.So this Authorize testcase will execute only after execution of Create . Here I want to copy the entire testdata of Create(after execution) testcase sheet¬† into another sheet of the same Excel file and also I want to set the name as Authorize for the newly copied sheet .

Please help me ,how can I achieve this using Apache Poi.

Add Comment
  • 2 Answer(s)
    Best answer

    Hi Ravinder,

    I do not think that you need to use any code for this, as it can be easily handle by simply name the ‘Sheet 2’ as Authorize. No need of renaming it in runtime. Still if you want to do it , you can use the below code:

    Second also I would suggest you to use the same first sheet, why to copy the same data to another.It always better to use the less code and make it simple, still if need it, thats what i got it from google:



    Professor Answered on August 20, 2014.
    Add Comment

    Thanks Lakshay..
    I will try with your simple solution only.

    Train Answered on August 21, 2014.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.