EasyXLS
http://forum.easyxls.com/

Formatting Unlocked Cells
http://forum.easyxls.com/viewtopic.php?f=5&t=162
Page 1 of 1

Author:  kevin kirk [ Tue Mar 11, 2008 6:09 am ]
Post subject:  Formatting Unlocked Cells

If I protect a worksheet and then unlock certain cells, I can edit those cells in Excel, but I can't format them (format options are disabled). Specifically I want the user to be able to change the foreground and background.

When protecting a worksheet manually you can specify what actions a user can take on the protected sheet. So, I could manually specify that a user can format cells, but can't select locked cells. That would be perfect.

Is there any way of doing this in code?

Example Javascript code;

var sheet;
var table;
var xls = Server.CreateObject("EasyXLS.ExcelDocument");

xls.easy_addWorksheet_2("Sheet1");
sheet = xls.easy_getSheetAt(0);
sheet.setSheetProtected(true);

table = sheet.easy_getExcelTable();
table.easy_getCell(0, 0).setLocked(false);
table.easy_getCell(0, 0).setValue('Kevin');
table.easy_getCell(0, 1).setValue('Kirk');

xls.easy_WriteXLSFile('test1.xls');
xls.Dispose();

Author:  oana [ Tue Mar 11, 2008 12:03 pm ]
Post subject:  Formatting Unlocked Cells

EasyXLS usually preserves as much unknown features as possible when loading a document, edit it and save it back. The Protection with Format cells option set is one of them. You can create a template, load it and then write it with a different name. The template can be an xls file that has the sheet protected with Format cells option set.

Page 1 of 1 All times are UTC - 4 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/