10-10-2024 08:00 AM - edited 10-10-2024 08:26 AM
Hallo,
I need to provide a method to password protect a report generated trough Report Toolkit (in Excel format) to be
used in a LabView project (LV 2013 SP1).
I tried using the password field provided by Save Report To File.vi but this don't behave the way I need.
My solution is to write down a .NET assembly which allows to modify the OpenXML report structure the same way as I was
using the Protect Sheet/Protect Workbook function within Excel and call this .NET method torugh Constructor/Invoke nodes.
Everything works but there's a but... in the typical workflow this method is invoked just after the report has been saved (using
Save Report To File.vi), unluckly quite often the call fails because Excel is locking the report file.
I found the solution depicted below but it looks a little bit too rude to me: there's another way to achieve the same result?
ReportLocker is the .NET assembly I coded (the source code can be found here: https://github.com/ROBINTsrl/ReportLocker ).
Bes regards,
Mike
Solved! Go to Solution.
10-10-2024 02:44 PM
I've not tried password-protecting my Excel reports, but one thing I have noticed (like maybe a decade ago) is that after I do a Save Report to File, I always do a Dispose Report, and then wait (trial by experiment, but could be tens of milliseconds) before trying to generate another Excel Report. Over the years, I've sometimes forgotten to do this, and the program lets me know ... I noticed you didn't do a Dispose Report at all, so you might be encountering behavior I haven't seen ...
Bob Schor
10-11-2024 01:18 AM
Yes! I needed to dispose the report to force Excel unlock the file.
I have noticed the Dispose Report.vi before posting but I have been foolded by the icon that shows a report and a garbage bin and I tought it was used to 'delete' a report. Anyway thnx.. I fixed that and now it works like a charm.