コード例 #1
0
        /// <summary>
        /// Get the height of specified rows.
        /// </summary>
        /// <param name="Unit">The unit of the height to be returned.</param>
        /// <param name="StartRowIndex">The row index of the start row.</param>
        /// <param name="EndRowIndex">The row index of the end row.</param>
        /// <returns>The height in the specified unit type.</returns>
        public double GetHeight(SLMeasureUnitTypeValues Unit, int StartRowIndex, int EndRowIndex)
        {
            if (StartRowIndex < 1)
            {
                StartRowIndex = 1;
            }
            if (StartRowIndex > SLConstants.RowLimit)
            {
                StartRowIndex = SLConstants.RowLimit;
            }
            if (EndRowIndex < 1)
            {
                EndRowIndex = 1;
            }
            if (EndRowIndex > SLConstants.RowLimit)
            {
                EndRowIndex = SLConstants.RowLimit;
            }

            long            lHeight = 0;
            int             i       = 0;
            SLRowProperties rp;

            for (i = StartRowIndex; i <= EndRowIndex; ++i)
            {
                if (slws.RowProperties.ContainsKey(i))
                {
                    rp       = slws.RowProperties[i];
                    lHeight += rp.HeightInEMU;
                }
                else
                {
                    lHeight += slws.SheetFormatProperties.DefaultRowHeightInEMU;
                }
            }

            double result = 0;

            switch (Unit)
            {
            case SLMeasureUnitTypeValues.Centimeter:
                result = SLConvert.FromEmuToCentimeter((double)lHeight);
                break;

            case SLMeasureUnitTypeValues.Emu:
                result = (double)lHeight;
                break;

            case SLMeasureUnitTypeValues.Inch:
                result = SLConvert.FromEmuToInch((double)lHeight);
                break;

            case SLMeasureUnitTypeValues.Point:
                result = SLConvert.FromEmuToPoint((double)lHeight);
                break;
            }

            return(result);
        }
コード例 #2
0
        /// <summary>
        /// Get the width of the specified columns.
        /// </summary>
        /// <param name="Unit">The unit of the width to be returned.</param>
        /// <param name="StartColumnIndex">The column index of the start column.</param>
        /// <param name="EndColumnIndex">The column index of the end column.</param>
        /// <returns>The width in the specified unit type.</returns>
        public double GetWidth(SLMeasureUnitTypeValues Unit, int StartColumnIndex, int EndColumnIndex)
        {
            if (StartColumnIndex < 1)
            {
                StartColumnIndex = 1;
            }
            if (StartColumnIndex > SLConstants.ColumnLimit)
            {
                StartColumnIndex = SLConstants.ColumnLimit;
            }
            if (EndColumnIndex < 1)
            {
                EndColumnIndex = 1;
            }
            if (EndColumnIndex > SLConstants.ColumnLimit)
            {
                EndColumnIndex = SLConstants.ColumnLimit;
            }

            long lWidth = 0;
            int  i      = 0;
            SLColumnProperties cp;

            for (i = StartColumnIndex; i <= EndColumnIndex; ++i)
            {
                if (slws.ColumnProperties.ContainsKey(i))
                {
                    cp      = slws.ColumnProperties[i];
                    lWidth += cp.WidthInEMU;
                }
                else
                {
                    lWidth += slws.SheetFormatProperties.DefaultColumnWidthInEMU;
                }
            }

            double result = 0;

            switch (Unit)
            {
            case SLMeasureUnitTypeValues.Centimeter:
                result = SLConvert.FromEmuToCentimeter((double)lWidth);
                break;

            case SLMeasureUnitTypeValues.Emu:
                result = (double)lWidth;
                break;

            case SLMeasureUnitTypeValues.Inch:
                result = SLConvert.FromEmuToInch((double)lWidth);
                break;

            case SLMeasureUnitTypeValues.Point:
                result = SLConvert.FromEmuToPoint((double)lWidth);
                break;
            }

            return(result);
        }