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


C# Range.get_Resize方法代码示例

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


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

示例1:

        ResizeRange
        (
            ref Range range,
            Int32 rows,
            Int32 columns
        )
        {
            Debug.Assert(range != null);
            Debug.Assert(rows > 0);
            Debug.Assert(columns > 0);

            range = range.get_Resize(rows, columns);
        }
开发者ID:cpatmoore,项目名称:bio,代码行数:13,代码来源:ExcelUtil.cs

示例2: SplitSingleAreaRange

        //*************************************************************************
        //  Method: SplitSingleAreaRange()
        //
        /// <summary>
        /// Splits a single-area range into subranges using a specified maximum
        /// number of rows per subrange.
        /// </summary>
        ///
        /// <param name="singleAreaRangeToSplit">
        /// Excel range to split into subranges via enumeration.  Must contain at
        /// least one row.  Cannot contain multiple areas.
        /// </param>
        ///
        /// <param name="maximumRowsPerSubrange">
        /// Maximum number of rows to include in each subrange.
        /// </param>
        //*************************************************************************
        public static IEnumerable<Range> SplitSingleAreaRange(
            Range singleAreaRangeToSplit,
            Int32 maximumRowsPerSubrange
            )
        {
            Debug.Assert(singleAreaRangeToSplit != null);
            Debug.Assert(singleAreaRangeToSplit.Areas.Count == 1);

            Int32 iTotalRows = singleAreaRangeToSplit.Rows.Count;

            Int32 iLastRowNumberOneBased =
            singleAreaRangeToSplit.Row + iTotalRows - 1;

            Range oCurrentSubrange = null;

            if (iTotalRows <= maximumRowsPerSubrange)
            {
            // There is no need to split the range into subranges.

            yield return (singleAreaRangeToSplit);

            yield break;
            }

            // Resize the range to the maximum number of rows.

            oCurrentSubrange = singleAreaRangeToSplit.get_Resize(
            maximumRowsPerSubrange, Missing.Value);

            yield return (oCurrentSubrange);

            while (true)
            {
            Int32 iLastSubrangeRowNumberOneBased =
                oCurrentSubrange.Row + oCurrentSubrange.Rows.Count - 1;

            if (iLastSubrangeRowNumberOneBased == iLastRowNumberOneBased)
            {
                // The subrange is at the end of the range.

                yield break;
            }

            // The current subrange needs to be shifted down.

            Int32 iRemainingRows =
                iLastRowNumberOneBased - iLastSubrangeRowNumberOneBased;

            Int32 iRowsInNextSubrange =
                Math.Min(iRemainingRows, maximumRowsPerSubrange);

            oCurrentSubrange = oCurrentSubrange.get_Resize(
                iRowsInNextSubrange, Missing.Value);

            oCurrentSubrange = oCurrentSubrange.get_Offset(
                maximumRowsPerSubrange, Missing.Value);

            yield return (oCurrentSubrange);
            }
        }
开发者ID:haisreekanth,项目名称:NetMap,代码行数:77,代码来源:ExcelRangeSplitter.cs

示例3: WriteSequenceRangeAt

        /// <summary>
        /// Write the given list of sequence ranges to a range
        /// </summary>
        /// <param name="outputStartRange">Starting cell of the output range</param>
        /// <param name="source">List of sequence range objects</param>
        /// <returns>Range with the data written</returns>
        private static Range WriteSequenceRangeAt(Range outputStartRange, List<ISequenceRange> source, bool writeLength)
        {
            object[,] output = new object[source.Count, writeLength ? 4 : 3];

            int currentRow = 0;
            foreach (ISequenceRange sequence in source)
            {
                output[currentRow, 0] = sequence.ID;
                output[currentRow, 1] = sequence.Start;
                output[currentRow, 2] = sequence.End;

                if (writeLength)
                {
                    output[currentRow, 3] = Math.Abs(sequence.End - sequence.Start).ToString();
                }

                currentRow++;
            }

            outputStartRange = outputStartRange.get_Resize(output.GetLength(0), output.GetLength(1));
            outputStartRange.Value2 = output;

            return outputStartRange;
        }
开发者ID:cpatmoore,项目名称:bio,代码行数:30,代码来源:VennToNodeXL.cs

示例4: WriteSequeceRangeHeader

        /// <summary>
        /// Write the column header for a sheet
        /// </summary>
        /// <param name="currentSheet">Current worksheet object</param>
        /// <param name="currentRange">Current range object</param>
        /// <param name="sequenceGroupName">Sequence group Name</param>
        /// <param name="sheetRowIndex">Sheet row index</param>
        /// <param name="sheetColumnIndex">Sheet column index</param>
        private static void WriteSequeceRangeHeader(
            Worksheet currentSheet,
            Range currentRange,
            string sequenceGroupName,
            ref int sheetRowIndex,
            ref int sheetColumnIndex,
            bool showBasePairCount)
        {
            sheetRowIndex++;
            currentRange = currentSheet.get_Range(GetColumnString(sheetColumnIndex) + sheetRowIndex, Type.Missing);
            currentRange = currentRange.get_Resize(1, showBasePairCount ? 2 : 1);
            currentRange.Merge();
            currentRange.Cells.Font.Bold = true;
            currentRange.HorizontalAlignment = XlHAlign.xlHAlignCenter;
            WriteRangeValue(currentRange, sequenceGroupName);
            sheetRowIndex++;

            if (showBasePairCount)
            {
                currentRange = currentSheet.get_Range(GetColumnString(sheetColumnIndex) + sheetRowIndex, Type.Missing);
                currentRange.Cells.Font.Bold = true;
                currentRange.HorizontalAlignment = XlHAlign.xlHAlignCenter;
                WriteRangeValue(currentRange, Resources.BASE_PAIR_COUNT);
                sheetColumnIndex++;
            }

            currentRange = currentSheet.get_Range(GetColumnString(sheetColumnIndex) + sheetRowIndex, Type.Missing);
            currentRange.Cells.Font.Bold = true;
            currentRange.HorizontalAlignment = XlHAlign.xlHAlignCenter;
            WriteRangeValue(currentRange, Resources.NUMBER_OF_RANGES);
            sheetColumnIndex++;

            sheetRowIndex -= 2;
        }
开发者ID:cpatmoore,项目名称:bio,代码行数:42,代码来源:BioRibbon.cs

示例5: RemoveSourceColumnHeader

        //*************************************************************************
        //  Method: RemoveSourceColumnHeader()
        //
        /// <summary>
        /// Removes the header from one of the source columns.
        /// </summary>
        ///
        /// <param name="oSourceColumn">
        /// The source column to remove the header from.
        /// </param>
        //*************************************************************************
        protected void RemoveSourceColumnHeader(
            ref Range oSourceColumn
            )
        {
            AssertValid();

            Int32 iRows = oSourceColumn.Rows.Count;

            if (iRows == 1)
            {
            OnInvalidSourceWorkbook(
                "There are no edges to import.",
                oSourceColumn.Worksheet, 1, 1
                );
            }

            // Trim the last row of the range, then shift the range down one row.

            oSourceColumn = oSourceColumn.get_Resize(iRows - 1, 1);
            oSourceColumn = oSourceColumn.get_Offset(1, 0);
        }
开发者ID:haisreekanth,项目名称:NetMap,代码行数:32,代码来源:EdgeWorkbookImporter.cs


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