当前位置: 首页>>代码示例>>C#>>正文


C# Range.Copy方法代码示例

本文整理汇总了C#中Range.Copy方法的典型用法代码示例。如果您正苦于以下问题:C# Range.Copy方法的具体用法?C# Range.Copy怎么用?C# Range.Copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Range的用法示例。


在下文中一共展示了Range.Copy方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InsertRange

 private static void InsertRange(Range rangeThatFitsAllCards)
 {
     rangeThatFitsAllCards.Copy();
     Globals.ThisAddIn.Application.CutCopyMode = XlCutCopyMode.xlCopy;
     rangeThatFitsAllCards.Insert(XlInsertShiftDirection.xlShiftDown);
 }
开发者ID:nate250,项目名称:TrelloExcel,代码行数:6,代码来源:ImportCardsPresenter.cs

示例2: WriteProductDataToStores

        public void WriteProductDataToStores(Dictionary<int, Dictionary<int,ProductEntry>> sPp, Dictionary<int, Product> products , Producers pList)
        {
            if (_isDisposed)
                throw new ObjectDisposedException("excel", "Either the excel app has been closed, or it was never opened");
            #if DEBUG
            Console.WriteLine("Getting Store Data From Template");
            #endif
            _rObj = _worksheet[0].Range[StartingCellTemplate, Missing.Value];
            _rObj = _rObj.End[XlDirection.xlDown];
            string downAddress = _rObj.Address[false, false, XlReferenceStyle.xlA1, Missing.Value, Missing.Value];
            _rObj = _worksheet[0].Range[StartingCellTemplate, downAddress];
            object[,] values = (object[,])_rObj.Value2;
            #if DEBUG
            Console.WriteLine("Writing ProductInformation to Stores");
            #endif
            int q;
            int lineList = 1;
            int lineDeList = 1;
            for (int i = 1; i <= values.GetLength(0); i++) {
                int key = Convert.ToInt32(values[i, 1]);
                if (!sPp.ContainsKey(key)) continue;
                bool listed = sPp[key].Any(entry => entry.Value.ListingState == ListingStatus.Listed || entry.Value.ListingState == ListingStatus.Forced);
                q = 1;
                if (listed) {
                    foreach (var product in products) {
                        if (sPp[key].ContainsKey(product.Key)) {
                                _worksheet[1].Cells[lineList + 1, StaticDataFieldCount + q] = sPp[key][product.Key].InventoryChange;
                            _worksheet[1].Cells[lineList + 1, StaticDataFieldCount + q].Interior.Color =
                                pList.GetProducerColourCodeFromProduct(product.Key);
                        }
                        q++;
                    }
                }
                _rObj = _worksheet[0].Range["A" + (i + 1), GetExcelColumnName(StaticDataFieldCount) + (i + 1)];
                if (listed) {
                    _rObj.Copy(_worksheet[1].Range["A" + (lineList + 1), GetExcelColumnName(StaticDataFieldCount) + (lineList + 1)]);
                    _worksheet[1].Cells[lineList + 1, StaticDataFieldCount + products.Count + 1] = DateTime.Now.ToShortDateString();
                    if (StaticDataFieldCountExtended > 0)
                    {
                        _rObj =
                            _worksheet[0].Range[
                                GetExcelColumnName(StaticDataFieldCount + 1) + (lineList + 1),
                                GetExcelColumnName(ExtendedDataReadEnd) + (lineList + 1)];

                        _rObj.Copy(_worksheet[1].Range[
                            GetExcelColumnName(StaticDataFieldCount + products.Count + 2) + (lineList + 1),
                            GetExcelColumnName(ExtendedDataReadEnd + products.Count + 1) + (lineList + 1)]);
                    }

                    lineList++;
                } else {
                    _rObj.Copy(_worksheet[2].Range["A" + (lineDeList + 1), GetExcelColumnName(StaticDataFieldCount) + (lineDeList + 1)]);

                    _worksheet[2].Cells[lineDeList + 1, StaticDataFieldCount + 1] = DateTime.Now.ToShortDateString();
                    lineDeList++;
                }
            }
            _rObj = _worksheet[1].Cells[2, StaticDataFieldCount + products.Count + 1];
            string upaddress = _rObj.Address[false, false, XlReferenceStyle.xlA1, Missing.Value, Missing.Value];
            _rObj = _rObj.End[XlDirection.xlDown];
            downAddress = _rObj.Address[false, false, XlReferenceStyle.xlA1, Missing.Value, Missing.Value];
            _rObj = _worksheet[1].Range[upaddress, downAddress];
            _rObj.EntireColumn.NumberFormat = "m/d/yyyy";
            _rObj = _worksheet[2].Cells[2, StaticDataFieldCount + 1];
            upaddress = _rObj.Address[false, false, XlReferenceStyle.xlA1, Missing.Value, Missing.Value];
            _rObj = _rObj.End[XlDirection.xlDown];
            downAddress = _rObj.Address[false, false, XlReferenceStyle.xlA1, Missing.Value, Missing.Value];
            _rObj = _worksheet[2].Range[upaddress, downAddress];
            _rObj.EntireColumn.NumberFormat = "m/d/yyyy";
        }
开发者ID:Zaneo,项目名称:WineExcel,代码行数:70,代码来源:ExcelIO.cs

示例3: SetupDocument

        public void SetupDocument(Dictionary<int, Product> products)
        {
            if (_isDisposed)
                throw new ObjectDisposedException("excel", "Either the excel app has been closed, or it was never opened");
            #if DEBUG
            Console.WriteLine("Writing Worksheet Names");
            #endif
            _worksheet[0].Name = "Template";
            _worksheet[1].Name = "Listing";
            _worksheet[2].Name = "Delisted";

            #if DEBUG
            Console.WriteLine("Copying Static Headers");
            #endif
            _rObj = _worksheet[0].Range["A1", GetExcelColumnName(StaticDataFieldCount) + 1];
            _rObj.Copy(_worksheet[1].Range["A1", GetExcelColumnName(StaticDataFieldCount) + 1]);
            _rObj.Copy(_worksheet[2].Range["A1", GetExcelColumnName(StaticDataFieldCount) + 1]);

            if (StaticDataFieldCountExtended > 0)
            {
                _rObj =
                    _worksheet[0].Range[
                        GetExcelColumnName(StaticDataFieldCount + 1) + 1, GetExcelColumnName(ExtendedDataReadEnd) + 1];
                _rObj.Copy(
                    _worksheet[1].Range[
                        GetExcelColumnName(StaticDataFieldCount + products.Count + 2) + 1,
                        GetExcelColumnName(ExtendedDataReadEnd + products.Count + 1) + 1]);
            }
            int q = 1;

            #if DEBUG
            Console.WriteLine("Writing Out Product Headers");
            #endif

            foreach (var product in products) {
                if (product.Value.Name != null) {
                    if (product.Value.ID < 0) {
                        _worksheet[1].Cells[1, StaticDataFieldCount + q] = product.Value.Name;
                    } else {
                        _worksheet[1].Cells[1, StaticDataFieldCount + q] = string.Format("{0}\n({1})", product.Value.Name,
                                                                           product.Key);
                    }

                } else {
                    _worksheet[1].Cells[1, StaticDataFieldCount + q] = product.Key;
                }

                q++;
            }
            _worksheet[1].Cells[1, + products.Count + StaticDataFieldCount + 1] = "Date Updated";
            _worksheet[2].Cells[1, StaticDataFieldCount + 1] = "Date Updated";
        }
开发者ID:Zaneo,项目名称:WineExcel,代码行数:52,代码来源:ExcelIO.cs

示例4: CopyColumn

        //*************************************************************************
        //  Method: CopyColumn()
        //
        /// <summary>
        /// Copies a column from the source worksheet to the destination NodeXL
        /// workbook.
        /// </summary>
        ///
        /// <param name="oSourceColumn">
        /// The source column to copy.
        /// </param>
        ///
        /// <param name="oDestinationColumnData">
        /// Data range of the destination column.
        /// </param>
        ///
        /// <param name="iDestinationRowOffset">
        /// Offset to copy to in the destination table, measured from the first
        /// row in the table's data range.
        /// </param>
        //*************************************************************************
        protected void CopyColumn(
            Range oSourceColumn,
            Range oDestinationColumnData,
            Int32 iDestinationRowOffset
            )
        {
            Debug.Assert(oSourceColumn != null);
            Debug.Assert(oDestinationColumnData != null);
            AssertValid();

            // The destination range will have more rows in it than the source
            // column if this is not the first copy operation.

            ExcelUtil.ResizeRange(ref oDestinationColumnData,
            oSourceColumn.Rows.Count, 1);

            ExcelUtil.OffsetRange(ref oDestinationColumnData,
            iDestinationRowOffset, 0);

            oSourceColumn.Copy(Missing.Value);
            ExcelUtil.PasteValues(oDestinationColumnData);
        }
开发者ID:haisreekanth,项目名称:NetMap,代码行数:43,代码来源:EdgeWorkbookImporter.cs

示例5: CopyPathContent

        private void CopyPathContent(ref  Range src, ref Range dest, ref BackgroundWorker wk)
        {
            try
            {
                src.Copy(Type.Missing);
                dest.PasteSpecial(XlPasteType.xlPasteFormats, XlPasteSpecialOperation.xlPasteSpecialOperationNone, Type.Missing, Type.Missing);
                wk.ReportProgress(0, Constants.SYS_CLEAR_CLIPBOARD);

                src.Copy(Type.Missing);
                dest.PasteSpecial(XlPasteType.xlPasteValuesAndNumberFormats, XlPasteSpecialOperation.xlPasteSpecialOperationNone, Type.Missing, Type.Missing);
                wk.ReportProgress(0, Constants.SYS_CLEAR_CLIPBOARD);

                src.Copy(Type.Missing);
                dest.PasteSpecial(XlPasteType.xlPasteColumnWidths, XlPasteSpecialOperation.xlPasteSpecialOperationNone, Type.Missing, Type.Missing);
                wk.ReportProgress(0, Constants.SYS_CLEAR_CLIPBOARD);
            }
            catch (Exception ex)
            {
                throw new Exception(Constants.PROC_ERROR_COPY_PASTE + Constants.PROC_ACTUAL_ERROR + ex.Message);
            }
        }
开发者ID:royhpr,项目名称:CTLabDataExtractor,代码行数:21,代码来源:XLSFileController.cs

示例6: CopyToClipboard

 public void CopyToClipboard(Range p_objFromRange)
 {
     p_objFromRange.Copy(Type.Missing);
 }
开发者ID:EdgarEDT,项目名称:myitoppsp,代码行数:4,代码来源:ExcelAccess.cs


注:本文中的Range.Copy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。