~ubuntu-branches/ubuntu/jaunty/horae/jaunty

« back to all changes in this revision

Viewing changes to 0CPAN/Spreadsheet-WriteExcel-2.15/examples/protection.pl

  • Committer: Bazaar Package Importer
  • Author(s): Carlo Segre
  • Date: 2008-02-23 23:13:02 UTC
  • mfrom: (2.1.2 hardy)
  • Revision ID: james.westby@ubuntu.com-20080223231302-mnyyxs3icvrus4ke
Tags: 066-3
Apply patch to athena_parts/misc.pl for compatibility with 
perl-tk 804.28.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/perl -w
2
 
 
3
 
########################################################################
4
 
#
5
 
# Example of cell locking and formula hiding in an Excel  worksheet via
6
 
# the Spreadsheet::WriteExcel module.
7
 
#
8
 
# reverse('�'), August 2001, John McNamara, jmcnamara@cpan.org
9
 
#
10
 
 
11
 
use strict;
12
 
use Spreadsheet::WriteExcel;
13
 
 
14
 
my $workbook  = Spreadsheet::WriteExcel->new("protection.xls");
15
 
my $worksheet = $workbook->add_worksheet();
16
 
 
17
 
# Create some format objects
18
 
my $locked    = $workbook->add_format(locked => 1);
19
 
my $unlocked  = $workbook->add_format(locked => 0);
20
 
my $hidden    = $workbook->add_format(hidden => 1);
21
 
 
22
 
# Format the columns
23
 
$worksheet->set_column('A:A', 42);
24
 
$worksheet->set_selection('B3:B3');
25
 
 
26
 
# Protect the worksheet
27
 
$worksheet->protect();
28
 
 
29
 
# Examples of cell locking and hiding
30
 
$worksheet->write('A1', 'Cell B1 is locked. It cannot be edited.');
31
 
$worksheet->write('B1', '=1+2', $locked);
32
 
 
33
 
$worksheet->write('A2', 'Cell B2 is unlocked. It can be edited.');
34
 
$worksheet->write('B2', '=1+2', $unlocked);
35
 
 
36
 
$worksheet->write('A3', "Cell B3 is hidden. The formula isn't visible.");
37
 
$worksheet->write('B3', '=1+2', $hidden);
38
 
 
39
 
$worksheet->write('A5', 'Use Menu->Tools->Protection->Unprotect Sheet');
40
 
$worksheet->write('A6', 'to remove the worksheet protection.   ');
41
 
 
42