Exemplo n.º 1
0
        /// <summary>
        /// Customization for copying the styles.
        /// </summary>
        /// <param name="rangelist">Range List</param>
        private void CopyStylesAsBiffToClipBoard(GridRangeInfoList rangelist)
        {
            GridExcelConverterControl gecc = new GridExcelConverterControl();
            ExcelEngine engine             = CreateEngine();
            IWorkbook   book  = engine.Excel.Workbooks.Create(1);
            IWorksheet  sheet = book.Worksheets[0];

            foreach (GridRangeInfo range in rangelist)
            {
                range.ExpandRange(1, 1, this.gridControl1.RowCount, this.gridControl1.ColCount);

                for (int iRow = range.Top; iRow <= range.Bottom; iRow++)
                {
                    for (int iColumn = range.Left; iColumn <= range.Right; iColumn++)
                    {
                        GridStyleInfo gridCell = this.gridControl1[iRow, iColumn];
                        if (gridCell.IsEmpty)
                        {
                            continue;
                        }
                        gecc.GridCellToExcel(this.gridControl1.Model, iRow, iColumn, sheet.Range[iRow, iColumn]);
                    }
                }
            }

            book.CopyToClipboard();
            book.Close();
            engine.Dispose();
        }