Reply to topic  [ 2 posts ] 
Lock cells 
Author Message
Reply with quote
Post Lock cells
I want to lock an Excel sheet from a java application.
How can I lock an entire Excel sheet or cell?


Wed Aug 09, 2006 2:10 am

Joined: Fri Feb 03, 2006 12:23 pm
Posts: 3
Reply with quote
Post Re: Lock cells
Using EasyXLS, you can lock/unlock an excel sheet or a cell very easy. In the following sample code the worksheet is locked and the first cell ("A1") is unlocked.


// Create an instance of the object used to generate excel files
ExcelDocument xls = new ExcelDocument(1);

// Lock the worksheet
xls.easy_getSheetAt(0).setSheetProtected(true);
// Unlock the first cell
((ExcelWorksheet)xls.easy_getSheetAt(0)).easy_getExcelTable().easy_getCell("A1").setLocked(false);

// Generate the excel file
System.out.println("Writing the file C:\\ProtectedSheet.xls");
xls.easy_WriteExcelFile("C:\\ProtectedSheet.xls");

// Confirm generation[/color]
if (xls.easy_getError() == "")
System.out.println("File successfully created.");
else
System.out.println("Error encountered: " + xls.easy_getError());

// Dispose memory
xls.Dispose();


Wed Aug 09, 2006 7:34 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.