Hi Amjad,
I did try to achieve my objective using Worksheet.copy( ) method. But, somehow its not fitting in to ny requirement. I am putting my scenario below, please suggest me if I am not doing it in right way.
Requirement
Moving sheets across workbooks by keeping the references of the formula intact.
Steps ( Please perform the steps in Ms Excel; i am attaching the sample files)
1> Check the formula on "Aggregation" sheet (Source.xls); cell C8. Its {='Contributor-1'!C8+'Contributor-2'!C8}.
2> Move the sheet "Contributor-1" to the other workbook (Target.xls). Now check the formula in[Source.xls]Aggregation!C8; it is {='[Target.xls]Contributor-1'!C8+'Contributor-2'!C8}. Here Ms Excel automatically changes the reference in the formula to point to the new workbook.
3> Move the sheet "Aggregation" to the other workbook (Target.xls). Now check the formula in[Target.xls]Aggregation!C8; it is {='Contributor-1'!C8+'[Source.xls]Contributor-2'!C8}. Here Ms Excel automatically changes the reference in the formula to point to the new workbook {Contributor-1'!C8}; at the same time since one of the contributor of the formula is still on the "Source.xls", it updates the reference of the 2nd contributor and point to the "Source.xls".
4> Move back both "Aggregation" and "Contributor-1" to "Source.xls" again. The formula on "Aggregation" sheet (Source.xls); cell C8 is back in its original form. Its {='Contributor-1'!C8+'Contributor-2'!C8}.
The above functionality is what I require which I am not able to achive using "Aspose.Cells for Java". I tried the copy option in excel itself and it does not suffice to my need. Going by the fact that Aspose behaves just as Ms Excel, I assumed that Worksheet.copy( ) is not the solution for me. However, please guide me if there is any way to achieve my requirement.
What is wrong with Copying Worksheet
1> Check the formula on "Aggregation" sheet (Source.xls); cell C8. Its {='Contributor-1'!C8+'Contributor-2'!C8}.
2> Copy the sheet "Contributor-1" to the other workbook (Target.xls). Now check the formula in[Source.xls]Aggregation!C8; it is {='Contributor-1'!C8+'Contributor-2'!C8}. Here Ms Excel still points to the same workbook.
3> Copy the sheet "Aggregation" to the other workbook (Target.xls). Now check the formula in[Source.xls]Aggregation!C8; it is { ='[Source.xls]Contributor-1'!C8+'[Source.xls]Contributor-2'!C8 }. Here Ms Excel automatically changes the reference in the formula to point to the source workbook; at the same time even if one of the contributor of the formula is present in the "Target.xls", it do not recognise it.
4> Copy the "Contributor-1" to "Source.xls" back again. Since there is already a sheet with the same name in source may be we have to delete the sheet from "Source.xls".
5> On deletion of "Cotributor-1" from "Source.xls"; the formula gets currupt. The formula on [Source.xls]Aggregation!C8 is now { =#REF!C8+'Contributor-2'!C8 } and on [Target.xls]Aggregation!C8 is now { ='[Source.xls]#REF'!C8+'[Source.xls]Contributor-2'!C8 }. Even if we copy the "Contibutor-1" from "Target.xls" to "Source.xls", there is no difference made. The formula is lost. This is where it goes wrong for me ....................
Please help me in achieving this objective. I am stuck here.
Thanks,
Malay