LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Report Toolkit - Excel file locking

Solved!
Go to solution

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?

michelesantucci_0-1728564841160.png

 

ReportLocker is the .NET assembly I coded (the source code can be found here: https://github.com/ROBINTsrl/ReportLocker  ).

 

Bes regards,

 Mike

 

0 Kudos
Message 1 of 3
(6,873 Views)
Solution
Accepted by michele.santucci

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

 

 

Message 2 of 3
(6,830 Views)

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.

0 Kudos
Message 3 of 3
(6,814 Views)