Re: PEAR Spreadsheet_Excel_Writer setLocked method

From: Date: Fri, 19 Jun 2009 09:26:52 +0000
Subject: Re: PEAR Spreadsheet_Excel_Writer setLocked method
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-294307@lists.php.net to get a copy of this message
Hey all, Any one use the PEAR Spreadsheet_Excel_Writer package? I need to know how to implement the setLocked method to lock out a cell, but can't figure out how this would be done. Do you add it as a format? But then how is it applied to a cell. It's not documented on the PEAR pages. Any help as always is greatly appreciated. Also, what about making a cell span more than one cell below and above it? I can't find a way to do this either. Thanks, Skip
I've used it for some time but never needed to lock a cell. Here is a piece of code that shows how to apply a format to a cell: <?php // Include the PEAR script require 'Spreadsheet/Excel/Writer.php'; // Stop displaying the errors so that the warnings don't get in your spreadsheet // ini_set('display_errors',0); // Instantiate a workbook $workbook = new Spreadsheet_Excel_Writer(); // Send it directly to the browser $workbook->send("test.xls"); // Set the version (very useful for compatibility) $workbook->setVersion(8); // Create a worksheet in the workbook $worksheet =& $workbook->addWorksheet('Test'); // Set input encoding $worksheet->setInputEncoding('UTF-8'); // Create a format $format_bold =& $workbook->addFormat(); $format_bold->setBold(); $format_bold->setHAlign('center'); $format_bold->setFgColor('yellow'); // Apply the format to a cell $worksheet->writeString(0, 0, "Test content", $format_bold); // Close the workbook $workbook->close(); ?> Hope it helps. I think that by doing something like this: $format_bold->setLocked(); while creating the format could do the trick but it is not tested. -- Thodoris

« previous php.general (#294307) next »