This is getting critical for us. We have files that need to be saved
with readonly recommended. The manual approach is to say:
File -> SaveAs -> Tools -> General -> Then check the ReadOnly
Recommended box.
I'm not the guy coding this up but I'm ok with python. I need to
either know how to create a new file that has this setting, or how to
copy from a blank file that has this setting that I can then write to.
On Friday, February 3, 2012 4:43:50 AM UTC+11, steveo wrote:
> This is getting critical for us. We have files that need to be saved > with readonly recommended. The manual approach is to say:
> File -> SaveAs -> Tools -> General -> Then check the ReadOnly > Recommended box.
> I'm not the guy coding this up but I'm ok with python. I need to > either know how to create a new file that has this setting, or how to > copy from a blank file that has this setting that I can then write to.
If you are driving Excel yourself e.g with pywin32 COM, then you should find that there is a ReadOnlyRecommended optional arg on the workbook SaveAs method.
If you are using xlwt:
option 1: There's a release being made real soon now. After the release I'll add not only the read_only_recommended caper but also the write_reservation password and user_name caper -- this latter prompts the user for a password if they want to open the workbook in modify mode; the idea is that the file creator hands out the password only to trusted users. Seems a much better idea to me. The two capers use the same record (FILESHARING) in the xls file so it's better to do both at once.
option 2: You get your boss to donate some brass to buy tranquilisers for the folk who want a release real soon, and I'll do it in the current release.
option 3: You do a gross hack on Workbook.py:
between these two lines:
before += self.__write_access_rec() before += self.__codepage_rec()
> if getattr(self, 'read_only_recommended', 0): > import struct > before += struct.pack('<5H', 0x005B, 6, 1, 0, 0)
> -- > You received this message because you are subscribed to the Google Groups > "python-excel" group. > To view this discussion on the web, visit > https://groups.google.com/d/msg/python-excel/-/NaG6rH9aIE8J. > To post to this group, send an email to python-excel@googlegroups.com. > To unsubscribe from this group, send email to > python-excel+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/python-excel?hl=en-GB.
I just wanted to thank you for the patch. I ramrodded it to the people who needed it, it was applied to the code and used by the application. It worked first time. Looking forward to the next release where it will be incorporated.
Isn't the internet great?
:-)
-- Time flies like the wind. Fruit flies like a banana. Stranger things have .0. happened but none stranger than this. Does your driver's license say Organ ..0 Donor?Black holes are where God divided by zero. Listen to me! We are all- 000 individuals! What if this weren't a hypothetical question? steveo at syslang.net
On Wednesday, February 15, 2012 7:40:27 AM UTC+11, steveo wrote:
> On 2/5/2012 4:03 AM, John Machin wrote:
> > # tested:
> > if getattr(self, 'read_only_recommended', 0): > > import struct > > before += struct.pack('<5H', 0x005B, 6, 1, 0, 0)
> I just wanted to thank you for the patch. I ramrodded it to the people who
> needed it, it was applied to the code and used by the application. It > worked > first time. Looking forward to the next release where it will be > incorporated.
> Thanks for the thanks.
It wasn't a patch; it was a gross hack. It won't be incorporated. Instead there will be a principled enhancement, which will include the write protection password facility.