Excel Track changes for Java code

How to get track changes for excel sheet through Java code?

@Vamsi_452,

Please try our latest version/fix: Aspose.Cells for Java v20.9.x. See the following sample code on how to use track changes feature for reference (the code is provided in .NET, so you may easily convert to Java by yourselves).
e.g.
Sample code:

Workbook workbook = new Workbook(file);
                foreach(RevisionLog log in workbook.Worksheets.RevisionLogs)
                {
                    RevisionCollection rvs = log.Revisions;
                    foreach (Revision rv in rvs)
                    {
                        switch (rv.Type)
                        {

                            case RevisionType.InsertDelete:
                                RevisionInsertDelete rrc = (RevisionInsertDelete)rv;
                                Console.WriteLine(string.Format("ActionType :{0}; newArea : {1}.", rrc.ActionType, rrc.CellArea));
                                Console.WriteLine(rrc.CellArea);
                                break;
                            case RevisionType.ChangeCells:
                                RevisionCellChange rcc = (RevisionCellChange)rv;
                                string str = string.Format("CellName :{0}; OldValue : {1} ;NewOld : {2}.", rcc.CellName, rcc.OldValue, rcc.NewValue);
                                Console.WriteLine(str);
                                break;
                            case RevisionType.MoveCells:
                                RevisionCellMove rm = (RevisionCellMove)rv;
                                Console.WriteLine(string.Format("SourceArea :{0}; newArea : {1}.", rm.SourceArea, rm.DestinationArea));
                                break;
                            case RevisionType.CustomView:
                                RevisionCustomView rcv = (RevisionCustomView)rv;
                                Console.WriteLine(string.Format("ActionType :{0}; guid : {1}.", rcv.ActionType, rcv.Guid));
                                break;
                            case RevisionType.Format:
                                RevisionFormat rfmt = (RevisionFormat)rv;
                                Console.WriteLine(string.Format("worksheet :{0}; area : {1}.", rfmt.Worksheet.Name, rfmt.Areas[0]));
                                break;
                            case RevisionType.InsertSheet:
                                RevisionInsertSheet ris = (RevisionInsertSheet)rv;
                                Console.WriteLine(string.Format("newsheet :{0}; sheetPosition : {1}.", ris.Name, ris.SheetPosition));
                                break;
                            case RevisionType.DefinedName:
                                RevisionDefinedName rdn = (RevisionDefinedName)rv;
                                Console.WriteLine(string.Format("Test :{0}; oldFormula :{1};  newformula : {2}.", rdn.Text, rdn.OldFormula, rdn.NewFormula));

                                break;
                            case RevisionType.RenameSheet:
                                RevisionRenameSheet rsnm = (RevisionRenameSheet)rv;
                                Console.WriteLine(string.Format("OldName :{0}; newName :{1}.", rsnm.OldName, rsnm.NewName));
                                break;
                            default:
                                Console.WriteLine(rv.Type);
                                break;
                        }
                    }
                }
1 Like

Thanks @Amjad_Sahi , it works well.
The only problem is that, with Aspose.Cells for Java, I can’t get the user and date of the revisions.
Is that possible to get a piece of info like “PersonA changed CellB on DateC”?
When I debug the code, I can see the value of the user and date of the revision. However, they are private fields of the RevisionLog
image.png (7.6 KB)

I’m not sure if it is the same in .NET
Could you help to provide public apis to get them in Java? Thanks in advance.

@Tony_Li,

We plan to provide some new apis for your requirement. Hopefully the new apis can be provided in next official version 23.1 in next month. Thank you.

@johnson.shi Thank you very much for you quick reply. Appreciate :+1: That would be very helpful.

@Tony_Li,

You are welcome.

Just for your reference, we logged a ticket with an id “CELLSNET-52429” for your requirements ( Support to get the author name and date time of revisions).

1 Like

@Tony_Li,

This is to inform you that your issue has been resolved now. The fix (having the new APIs) will be included in our upcoming release (Aspose.Cells v23.1) which is scheduled in the first half of January 2023. You will be notified once the next release is published.

1 Like

The issues you have found earlier (filed as CELLSNET-52429) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi

If you use Java code, please try Aspose.Cells for Java 23.1.

It works very well, thanks all :slight_smile: :+1:

@Tony_Li,

Thanks for your feedback.

Good to know that your issue is resolved by the new version. Feel free to contact us any time if you have further comments or questions.