When you say "flag the file as read-only", do you mean changing the attributes/permissions of the file? If so, I'll address that.
Attributes (Windows)/Permissions (*nix) are "meta" information on the file system. In NTFS, this data is stored in the Master File Table (MFT). In ext3, this data would be stored in the inode. This means that renaming the file, moving the file, or changing permissions of the file should not change the contents of the file, which is what is hashed.
You could always run a quick test to confirm:
>rem Sum the file first.
>sha256sum ExcelFile.xlsx
4bb7303b56a728665f639c36ffdc6169ac4debd774a0e9bedd27ca15b451c8ad *ExcelFile.xlsx
>rem Check the attributes of the file.
>attrib ExcelFile.xlsx
A C:\Users\User\Documents\ExcelFile.xlsx
>rem Add the read-only attribute.
>attrib +r ExcelFile.xlsx
>rem Sum the file again.
>sha256sum ExcelFile.xlsx
4bb7303b56a728665f639c36ffdc6169ac4debd774a0e9bedd27ca15b451c8ad *ExcelFile.xlsx
>rem Rename the file.
>ren ExcelFile.xlsx ExcelFile.xlsx2
>rem Sum the file again.
>sha256sum ExcelFile.xlsx2
4bb7303b56a728665f639c36ffdc6169ac4debd774a0e9bedd27ca15b451c8ad *ExcelFile.xlsx2
>rem Check the attributes of the file again.
>attrib ExcelFile.xlsx2
A R C:\Users\User\Documents\ExcelFile.xlsx2
>rem Remove the read-only attribute.
>attrib -r ExcelFile.xlsx2
>rem Rename the file again.
>ren ExcelFile.xlsx2 ExcelFile.xlsx
>rem Sum the file again.
>sha256sum ExcelFile.xlsx
4bb7303b56a728665f639c36ffdc6169ac4debd774a0e9bedd27ca15b451c8ad *ExcelFile.xlsx
>
I also tried to open the file when it was set to read-only in Excel (also had [Read Only]
in the title bar). While the file was open, I ran sha256sum again and the hash was still unchanged. I tried to save changes to the file and it prompted me for a new file name.