EasyXLS http://forum.easyxls.com/ |
|
Lock cells http://forum.easyxls.com/viewtopic.php?f=5&t=26 |
Page 1 of 1 |
Author: | Hagne [ Wed Aug 09, 2006 2:10 am ] |
Post subject: | Lock cells |
I want to lock an Excel sheet from a java application. How can I lock an entire Excel sheet or cell? |
Author: | tavi [ Wed Aug 09, 2006 7:34 am ] |
Post subject: | 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(); |
Page 1 of 1 | All times are UTC - 4 hours |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |