예제 #1
0
 public void Delete(DeleteShiftDirection deleteShiftDirection)
 {
     AssertNotDisposed();
     Excel.Range _range = _GetRange();
     _range.Delete(EnumConvert.ConvertDeleteShiftDirection(deleteShiftDirection));
     Marshal.ReleaseComObject(_range);
 }
예제 #2
0
        public void SetBorder(BorderThickness leftBorderThickness, BorderThickness topBorderThickness,
                              BorderThickness rightBorderThickness, BorderThickness bottomBorderThickness)
        {
            AssertNotDisposed();
            Excel.Range _range     = _GetRange();
            var         blackColor = ColorTranslator.ToOle(Color.Black);

            Excel.Borders _borders      = _range.Borders;
            Excel.Border  _leftBorder   = _borders[Excel.XlBordersIndex.xlEdgeLeft];
            Excel.Border  _topBorder    = _borders[Excel.XlBordersIndex.xlEdgeTop];
            Excel.Border  _rightBorder  = _borders[Excel.XlBordersIndex.xlEdgeRight];
            Excel.Border  _bottomBorder = _borders[Excel.XlBordersIndex.xlEdgeBottom];
            _leftBorder.LineStyle   = leftBorderThickness == BorderThickness.None ? Excel.XlLineStyle.xlLineStyleNone : Excel.XlLineStyle.xlContinuous;
            _topBorder.LineStyle    = topBorderThickness == BorderThickness.None ? Excel.XlLineStyle.xlLineStyleNone : Excel.XlLineStyle.xlContinuous;
            _rightBorder.LineStyle  = rightBorderThickness == BorderThickness.None ? Excel.XlLineStyle.xlLineStyleNone : Excel.XlLineStyle.xlContinuous;
            _bottomBorder.LineStyle = bottomBorderThickness == BorderThickness.None ? Excel.XlLineStyle.xlLineStyleNone : Excel.XlLineStyle.xlContinuous;
            _leftBorder.Weight      = EnumConvert.ConvertBorderThickness(leftBorderThickness);
            _leftBorder.Color       = blackColor;
            _topBorder.Weight       = EnumConvert.ConvertBorderThickness(topBorderThickness);
            _topBorder.Color        = blackColor;
            _rightBorder.Weight     = EnumConvert.ConvertBorderThickness(rightBorderThickness);
            _rightBorder.Color      = blackColor;
            _bottomBorder.Weight    = EnumConvert.ConvertBorderThickness(bottomBorderThickness);
            _bottomBorder.Color     = blackColor;
            Marshal.ReleaseComObject(_bottomBorder);
            Marshal.ReleaseComObject(_rightBorder);
            Marshal.ReleaseComObject(_topBorder);
            Marshal.ReleaseComObject(_leftBorder);
            Marshal.ReleaseComObject(_borders);
            Marshal.ReleaseComObject(_range);
        }
예제 #3
0
        public void InsertIntoLocation(IWorksheet targetWorksheet, int targetRow, int targetColumn,
                                       InsertShiftDirection shiftDirection)
        {
            AssertNotDisposed();
            var targetRange = targetWorksheet.GetRange(targetRow, targetColumn, targetRow + EndRow - StartRow,
                                                       targetColumn + EndColumn - StartColumn) as Range;

            if (targetRange == null)
            {
                throw new InvalidOperationException("Implementation of this method depends on another Office Interop wrapper.");
            }

            Excel.Range _range       = _GetRange();
            Excel.Range _targetRange = targetRange._GetRange();
            lock (Synchronization.ClipboardSyncRoot)
            {
                _targetRange.Insert(EnumConvert.ConvertInsertShiftDirection(shiftDirection), _range.Copy());
            }

            Marshal.ReleaseComObject(_targetRange);
            Marshal.ReleaseComObject(_range);
        }