john.tm has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, Is it possible via 'perl' to disable users from cut, copy & pasting data. I have created a xlsx worksheet with the use of the Excel::Writer::XLSX; module, but even though numerous columns have format vailadations set, it is still possible to copy data into those cells. this is just a short sample of my script below.

#!/usr/bin/perl -w use strict; use Spreadsheet::WriteExcel; use Excel::Writer::XLSX; my $workbook = Excel::Writer::XLSX->new("C:\\Temp\\test.xlsx"); my $worksheet1 = $workbook->add_worksheet(); $worksheet1->freeze_panes( 1, 0 ); my $unlocked = $workbook->add_format( locked => 0 ); my $header = $workbook->add_format( locked => 1 ); my $header2 = $workbook->add_format( locked => 1 ); $header->set_color('white'); $header->set_align('left'); $header->set_pattern(); $header->set_bg_color('orange'); $worksheet1->protect(); for my $i ( 0 .. 60 ) { $worksheet1->write( 0, $i, 'header', $header, ); } my @score_attain = ( 'P1', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7', 'P8', '1W', '1W+', '1B', '1B+', '1S', '1S+', '2W', '2W+', '2B', '2B+', '2S', '2S+', '3W', '3W+', '3B', '3B+', '3S', '3S+', '4W', '4W+', '4B', '4B+', '4S', '4S+', '5W', '5W+', '5B', '5B+', '5S', '5S+', ); for my $i ( 1 .. 1000 ) { $worksheet1->data_validation( $i, 6, { validate => 'list', source => [@score_attain], input_title => 'Select an option', input_message => 'Select a value from the drop down list', error_title => 'Input value is not valid!', error_message => 'Select a value from the drop down list', } ); } for my $i ( 1 .. 100 ) { for my $j ( 0 .. 60 ) { $worksheet1->set_row( $i, undef, $unlocked ); $worksheet1->{CutCopyMode} = 0; } }

Replies are listed 'Best First'.
Re: Perl script to disable cut copy % paste in an xlsx worksheet
by Gangabass (Vicar) on Apr 08, 2016 at 00:12 UTC