Monday, May 6, 2013

removing a row in spreadsheetgear from a range

You can't do this   range( "1:1").delete - you will get an error that s/sh gear can only delete a full row

You can't refer to the underlying location values

you have to refer to the row of the range as if the range is a full spreadsheet

this is what I did
 public static IRange RemoveHeader(IRange range)
        {
            try
            {
                string startingCol ="a";
                string endingCol = GetExcelColumnName(range.ColumnCount);
                int startRow =  2;
                int endRow = range.RowCount;
                string newrange = string.Format("{0}{1}:{2}{3}", startingCol, startRow, endingCol, endRow);
                if (!range.Union(range.Range[newrange]).Equals(range))
                {
                    throw new EExcelUtilsRangeOutOfBoundsOfData();
                }
                return range[newrange];
            }
            catch
            {
                throw new EExcelUtilsRangeOutOfBoundsOfData();
            }

        }

No comments:

Post a Comment