示例#1
0
        /// <summary>
        /// Protège la feuille, sans mot de passe
        /// </summary>
        public bool ProtegerFeuille()
        {
            object Vrai = (object)true;
            object Faux = (object)false;

            try
            {
                _MaFeuille.Protect(_M, Vrai, Vrai, Vrai, _M, _M, _M, _M, _M, _M, _M, _M, _M, _M, _M, _M);
                return(true);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return(false);
            }
        }
示例#2
0
        private void protect()
        {
            mSheet.Cells.Locked = false;

            if (this.DataList.Count > 0)
            {
                // only protect data cell, so if data is empty, ignore it
                Range startCell  = mSheet.Cells[mStartRow + 2, mStartCol];
                Range endCell    = mSheet.Cells[mEndRow, mEndCol];
                Range tableRange = mSheet.Range[startCell, endCell];
                tableRange.Locked = true;
            }

            mSheet.Protect(Password, AllowFormattingCells: true, AllowFormattingColumns: true, AllowFormattingRows: true);
        }