When 「CreateWriteAccess()」 is executed, it is not pointed to field「writeAccess」, and in 「WriteProtectWorkbook()」, the call of 「FileSharing」 is placed in front of 「WriteAccess」, cause when calls Property 「WriteAccess」, because field 「writeAccess」 is null, WriteAccessRecord is created repeatedly and added to InterfaceEndRecord.
The normal Record order should be as follows.
[INTERFACEEND/]
[WriteAccess]
[FILESHARING]
But the order of this situation is as follow.
[INTERFACEEND/]
[WriteAccess]
[WriteAccess]
[FILESHARING]
Although I don’t know the reason, apparently two [WriteAccess] in [INTERFACEEND/] and [FILESHARING] will cause "WriteProtectWorkbook" to not work properly.
For the current version to work normally, you must call 「WriteAccess」 before calling 「WriteProtectWorkbook()」
My English is very bad, so I use google translation, if the description is not clear, please forgive me>
If directly new HSSFWorkbook(),WriteProtectWorkbook is not workig,The reason is as follows.
The following code is from InternalWorkbook.cs
When 「CreateWriteAccess()」 is executed, it is not pointed to field「writeAccess」, and in 「WriteProtectWorkbook()」, the call of 「FileSharing」 is placed in front of 「WriteAccess」, cause when calls Property 「WriteAccess」, because field 「writeAccess」 is null, WriteAccessRecord is created repeatedly and added to InterfaceEndRecord.
The normal Record order should be as follows. [INTERFACEEND/] [WriteAccess] [FILESHARING]
But the order of this situation is as follow. [INTERFACEEND/] [WriteAccess] [WriteAccess] [FILESHARING]
Although I don’t know the reason, apparently two [WriteAccess] in [INTERFACEEND/] and [FILESHARING] will cause "WriteProtectWorkbook" to not work properly. For the current version to work normally, you must call 「WriteAccess」 before calling 「WriteProtectWorkbook()」
The orderof Records generated at this time is as follows. [INTERFACEEND/] [WriteAccess] [FILESHARING] [WriteAccess]
Although there is still an extra [WriteAccess], it can work at least in version 2.5.5, and the previous version has not yet been tested.