示例#1
0
        /// <summary>
        /// Creates a request to autosize a range of rows/columns to fit the data they contain.
        /// <para></para>
        /// THROWS: ArgumentOutOfRangeException; InvalidOperationException
        /// </summary>
        /// <param name="spreadsheetId">The id of the sheets doc</param>
        /// <param name="tabName">The name of the tab to autosize</param>
        /// <param name="dimension">Specifies wether rows or columns are autosized</param>
        /// <param name="startIndex">The point the autosize range begins</param>
        /// <param name="endIndex">The Point the autosize range ends</param>
        /// <returns></returns>
        private static Request requestDimensionAutoSize(string spreadsheetId, string tabName, int?startIndex = null, int?endIndex = null, Dimension dimension = Dimension.Columns)
        {
            if (dimension >= Dimension.Count)
            {
                throw new ArgumentOutOfRangeException("dimension", m_errorInvalidTabDimension);
            }

            if (startIndex > endIndex)
            {
                throw new InvalidOperationException(m_errorInvalidRange);
            }

            AutoResizeDimensionsRequest autoSizeDimensionProperties = new AutoResizeDimensionsRequest();

            autoSizeDimensionProperties.Dimensions            = new DimensionRange();
            autoSizeDimensionProperties.Dimensions.SheetId    = getTabIndex(spreadsheetId, tabName);
            autoSizeDimensionProperties.Dimensions.Dimension  = m_dimensions[(int)dimension];
            autoSizeDimensionProperties.Dimensions.StartIndex = startIndex;
            autoSizeDimensionProperties.Dimensions.EndIndex   = endIndex;

            Request request = new Request();

            request.AutoResizeDimensions = autoSizeDimensionProperties;

            return(request);
        }
示例#2
0
        public AutoResizeDimensionsRequest AddAutoResizeDimensions(int sheetId, string direction = "COLUMNS", int?first = null, int?last = null)
        {
            var request = new AutoResizeDimensionsRequest
            {
                Dimensions = new DimensionRange
                {
                    SheetId    = sheetId,
                    StartIndex = first,
                    EndIndex   = last,
                    Dimension  = direction
                }
            };

            this.Requests.Add(new Request {
                AutoResizeDimensions = request
            });
            return(request);
        }