public void SortRanges(CellDescriptor cd1Top, CellDescriptor cd1Bottom, int SortColumnIdx1, bool sortAscending1, int SortColumnIdx2, bool sortAscending2)
        {
            try
            {
                _Worksheet ws = (_Worksheet)(this.worksheet);
                ws.Activate();
                Range sortRange1 = ws.get_Range(GetCellName(cd1Top), GetCellName(cd1Bottom));
                sortRange1.Sort
                    (sortRange1.Columns[SortColumnIdx1, _MISSING_], ((sortAscending1) ? XlSortOrder.xlAscending : XlSortOrder.xlDescending),
                    sortRange1.Columns[SortColumnIdx2, _MISSING_], _MISSING_, ((sortAscending2) ? XlSortOrder.xlAscending : XlSortOrder.xlDescending),
                    _MISSING_, XlSortOrder.xlAscending,
                    XlYesNoGuess.xlNo, _MISSING_, _MISSING_,
                    XlSortOrientation.xlSortColumns,
                    XlSortMethod.xlPinYin,
                    XlSortDataOption.xlSortNormal,
                    XlSortDataOption.xlSortNormal,
                    XlSortDataOption.xlSortNormal);

                /*
                 * SortRange(cd1Top, cd1Bottom, SortColumnIdx1, sortAscending1);
                 * SortRange(cd1Top, cd1Bottom, SortColumnIdx2, sortAscending2);*/
            }
            catch (Exception e)
            {
            }
        }
        /// <summary>
        /// Gets Span Name
        /// </summary>
        /// <param name="cdFrom"></param>
        /// <param name="cdTo"></param>
        /// <returns></returns>
        public string GetSpanName(CellDescriptor cdFrom, CellDescriptor cdTo)
        {
            Range cRange1 = (Range)(worksheet.Cells[cdFrom.Row, cdFrom.Col]);
            Range cRange2 = (Range)(worksheet.Cells[cdTo.Row, cdTo.Col]);
            Range cRange  = (Range)(worksheet.get_Range(cRange1.AddressLocal, cRange2.AddressLocal));

            return(cRange.AddressLocal);
        }
        public void SortRange(CellDescriptor cd1, CellDescriptor cd2, int SortColumnIdx, bool sortAscending = true)
        {
            _Worksheet ws = (_Worksheet)(this.worksheet);

            ws.Activate();
            Range sortRange = ws.get_Range(GetCellName(cd1), GetCellName(cd2));

            sortRange.Sort
                (sortRange.Columns[SortColumnIdx, _MISSING_], XlSortOrder.xlDescending,
                _MISSING_, _MISSING_, ((sortAscending)?XlSortOrder.xlAscending:XlSortOrder.xlDescending),
                _MISSING_, XlSortOrder.xlAscending,
                XlYesNoGuess.xlNo, _MISSING_, _MISSING_,
                XlSortOrientation.xlSortColumns,
                XlSortMethod.xlPinYin,
                XlSortDataOption.xlSortNormal,
                XlSortDataOption.xlSortNormal,
                XlSortDataOption.xlSortNormal);
        }
        Range setCellValue(CellDescriptor cd)
        {
            Range cRange = (Range)(worksheet.Cells[cd.Row, cd.Col]);

            if (!string.IsNullOrEmpty(cd.Value))
            {
                worksheet.Cells[cd.Row, cd.Col] = cd.Value;
            }
            if (0 != cd.Color)
            {
                cRange.Font.Color = cd.Color;
            }
            if (0 != cd.BgColor)
            {
                cRange.Interior.Color = cd.BgColor;
            }
            if (cd.MakeBold)
            {
                cRange.Font.Bold = true;
            }
            return(cRange);
        }
        /// <summary>
        /// Gets a Cell Name
        /// </summary>
        /// <param name="cd">Give a name of the cell at cd.Row and cd.Col</param>
        /// <returns>cell name</returns>
        public string GetCellName(CellDescriptor cd)
        {
            Range cRange = (Range)(worksheet.Cells[cd.Row, cd.Col]);

            return(cRange.AddressLocal);
        }