Raysoft.Framework.Spead.SpreadHelper

//======================================================================
//
//        Copyright (C) 2007-2008 RaySoft
//        All rights reserved
//        guid1:              4b887cc8-ac8c-4397-bff3-628761c59f48
//        guid2:              80f46765-0f16-44c4-a542-2b7eb38522f7
//        guid3:              923c4a79-98ea-4148-8d1a-e13993a55545
//        guid4:              da27be46-708a-453f-aa4d-25e96d116917
//        guid5:              05158992-6744-44d1-9bcb-cb422e35afbf
//        CLR版本:            2.0.50727.5448
//        新建项输入的名称:   SpreadHelper
//        机器名称:           RAY-PC
//        注册组织名:         
//        命名空间名称:       RaySoft.Common
//        文件名:             SpreadHelper
//        当前系统时间:       2011/11/15 12:39:08
//        当前登录用户名:     Administrator
//        创建年份:           2011
//
//        created by Ray at  2011/11/15 12:39:08
//
//======================================================================

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using FarPoint.Win;
using FarPoint.Win.Spread;
using System.Windows.Forms;

namespace Raysoft.Framework.Spread
{
    public class SpreadHelper
    {
        #region 设置单元格字体样式

        /// <summary>
        /// 设置单元格字体样式
        /// </summary>
        /// <param name="fpSpread"></param>
        /// <param name="cellrange"></param>
        /// <param name="fontFamliy"></param>
        /// <param name="fontStyle"></param>
        /// <param name="fontSize"></param>
        /// <returns></returns>
        public static bool SetFont(FpSpread fpSpread, FarPoint.Win.Spread.Model.CellRange[] cellrange, string fontFamliy, FontStyle fontStyle, float fontSize)
        {
            foreach (FarPoint.Win.Spread.Model.CellRange range in cellrange)
            {
                for (int i = range.Row; i < range.RowCount + range.Row; i++)
                {
                    for (int j = range.Column; j < range.ColumnCount + range.Column; j++)
                    {
                        Font font = new Font(fontFamliy, fontSize, fontStyle);
                        fpSpread.ActiveSheet.Cells[i, j].Font = font;
                    }
                }
            }
            return true;
        }

        #endregion

        #region 设置单元格表格线

        /// <summary>
        /// 设置单元格表格线
        /// </summary>
        /// <param name="fps"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="leftBorder"></param>
        /// <param name="topBorder"></param>
        /// <param name="rightBorder"></param>
        /// <param name="bottomBorder"></param>
        /// <returns></returns>
        public static bool SetComplexSingeCellBorders(FpSpread fps, int row, int col, FarPoint.Win.ComplexBorderSide leftBorder, FarPoint.Win.ComplexBorderSide topBorder, FarPoint.Win.ComplexBorderSide rightBorder, FarPoint.Win.ComplexBorderSide bottomBorder)
        {
            if (leftBorder != null & topBorder == null & rightBorder == null & bottomBorder == null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(leftBorder, null, null, null);
            }//Left
            else if (leftBorder == null & topBorder != null & rightBorder == null & bottomBorder == null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(null, topBorder, null, null);
            }//Top
            else if (leftBorder == null & topBorder == null & rightBorder != null & bottomBorder == null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(null, null, rightBorder, null);
            }//Right
            else if (leftBorder == null & topBorder == null & rightBorder == null & bottomBorder != null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(null, null, null, bottomBorder);
            }//Bottom
            else if (leftBorder != null & topBorder != null & rightBorder == null & bottomBorder == null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(leftBorder, topBorder, null, null);
            }//Left + Top
            else if (leftBorder != null & topBorder == null & rightBorder != null & bottomBorder == null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(leftBorder, null, rightBorder, null);
            }//Left + Right
            else if (leftBorder != null & topBorder == null & rightBorder == null & bottomBorder != null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(leftBorder, null, null, bottomBorder);
            }//Left + Bottom
            else if (leftBorder == null & topBorder != null & rightBorder != null & bottomBorder == null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(null, topBorder, rightBorder, null);
            }//Top + Right
            else if (leftBorder == null & topBorder != null & rightBorder == null & bottomBorder != null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(null, topBorder, null, bottomBorder);
            }//Top + Bottom
            else if (leftBorder == null & topBorder == null & rightBorder != null & bottomBorder != null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(null, null, rightBorder, bottomBorder);
            }//Right + Bottom
            else if (leftBorder != null & topBorder != null & rightBorder != null & bottomBorder == null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(leftBorder, topBorder, rightBorder, null);
            }//Left + Top + Right
            else if (leftBorder != null & topBorder != null & rightBorder == null & bottomBorder != null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(leftBorder, topBorder, null, bottomBorder);
            }//Left + Top + Bottom
            else if (leftBorder != null & topBorder == null & rightBorder != null & bottomBorder != null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(leftBorder, topBorder, null, bottomBorder);
            }//Left + Right + Bottom
            else if (leftBorder == null & topBorder != null & rightBorder != null & bottomBorder != null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(null, topBorder, rightBorder, bottomBorder);
            }//Top + Right + Bottom 原版中没有这一项.
            else if (leftBorder != null & topBorder != null & rightBorder != null & bottomBorder != null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(leftBorder, topBorder, leftBorder, bottomBorder);
            }//Left + Top + Right + Bottom
            else
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(null, null, null, null);
            }//All Null
            return true;
        }

        #endregion

        #region 清除表格线
        /// <summary>
        /// 清除表格线
        /// </summary>
        /// <param name="fps"></param>
        /// <returns></returns>
        public static bool ClearAllCellBoders(FpSpread fps)
        {
            fps.ActiveSheet.HorizontalGridLine = new GridLine(FarPoint.Win.Spread.GridLineType.None);
            fps.ActiveSheet.VerticalGridLine = new GridLine(FarPoint.Win.Spread.GridLineType.None);
            return true;
        }
        #endregion

        #region 设置单元格对齐

        /// <summary>
        /// 设置单元格对齐
        /// </summary>
        /// <param name="fps"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="row2"></param>
        /// <param name="col2"></param>
        /// <param name="HorizontalAlignment"></param>
        /// <param name="VerticalAlignment"></param>
        /// <returns></returns>
        public static bool setCellAlignmentForRange(FpSpread fps, int row, int col, int row2, int col2, CellHorizontalAlignment HorizontalAlignment, CellVerticalAlignment VerticalAlignment)
        {
            fps.ActiveSheet.Cells[row, col, row2, col2].HorizontalAlignment = HorizontalAlignment;
            fps.ActiveSheet.Cells[row, col, row2, col2].VerticalAlignment = VerticalAlignment;
            return true;
        }
        #endregion

        #region 设置单元格的值

        /// <summary>
        /// 设置单元格的值
        /// </summary>
        /// <param name="fps"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="textVal"></param>
        /// <returns></returns>
        public static bool setValue(FpSpread fps, int row, int col, string textVal)
        {
            fps.ActiveSheet.SetValue(row, col, textVal);
            return true;
        }

        #endregion

        #region 设置单元格背景颜色

        /// <summary>
        /// 设置单元格背景颜色
        /// </summary>
        /// <param name="fps"></param>
        /// <param name="row"></param>
        /// <param name="row2"></param>
        /// <param name="col"></param>
        /// <param name="col2"></param>
        /// <param name="theBackColor"></param>
        /// <returns></returns>
        public static bool setBackColorForRange(FpSpread fps, int row, int row2, int col, int col2, Color theBackColor)
        {
            fps.ActiveSheet.Cells[row, col, row2, col2].BackColor = theBackColor;
            return true;
        }

        #endregion

        #region 设置单元格前景颜色

        /// <summary>
        /// 设置单元格前景颜色
        /// </summary>
        /// <param name="fps"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="row2"></param>
        /// <param name="col2"></param>
        /// <param name="theForceColor"></param>
        /// <returns></returns>
        public static bool setForceColorForRange(FpSpread fps, int row, int col, int row2, int col2, Color theForceColor)
        {
            fps.ActiveSheet.Cells[row, col, row2, col2].ForeColor = theForceColor;
            return true;
        }

        #endregion

        #region 设置单元格文本
        /// <summary>
        /// 设置单元格的文本
        /// </summary>
        /// <param name="fps"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="sText"></param>
        /// <returns></returns>
        public static bool setText(FpSpread fps, int row, int col, string sText)
        {
            fps.ActiveSheet.SetValue(row, col, sText);
            return true;
        }
        #endregion

        #region 设置指定行行高

        public static bool setRowHeightForRange(FpSpread fps, int row, int col, int row2, int col2, Single rowHeightInPixels)
        {
            fps.ActiveSheet.Cells[row, col, row2, col2].Row.Height = rowHeightInPixels;
            return true;
        }
        #endregion

        #region 设置指定列列宽

        public static bool setColumnWidthForRange(FpSpread fps, int row, int col, int row2, int col2, Single columnWidthInPixels)
        {
            fps.ActiveSheet.Cells[row, col, row2, col2].Column.Width = columnWidthInPixels;
            return true;
        }
        #endregion

        #region 设置单元格简单表格线
        /// <summary>
        /// 设置单元格简单表格线
        /// </summary>
        /// <param name="fps"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="lineWidthInPixels"></param>
        /// <returns></returns>
        public static bool setSingleCellBorders(FpSpread fps, int row, int col, int lineWidthInPixels)
        {
            ComplexBorderSide leftBorder = new ComplexBorderSide(Color.Black, lineWidthInPixels);
            ComplexBorderSide rightBorder = new ComplexBorderSide(Color.Black, lineWidthInPixels);
            ComplexBorderSide topBorder = new ComplexBorderSide(Color.Black, lineWidthInPixels);
            ComplexBorderSide bottomBorder = new ComplexBorderSide(Color.Black, lineWidthInPixels);
            fps.ActiveSheet.Cells[row, col].Border = new ComplexBorder(leftBorder, topBorder, rightBorder, bottomBorder);
            return true;
        }
        #endregion

        #region 设置指定区域简单表格线
        /// <summary>
        /// 设置指定区域简单表格线
        /// </summary>
        /// <param name="fps"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="?"></param>
        /// <param name="?"></param>
        /// <param name="col2"></param>
        /// <param name="lineWidthInPixels"></param>
        /// <returns></returns>
        public static bool SetSingleCellBordersForRange(FpSpread fps, int row, int col, int row2, int col2, int lineWidthInPixels)
        {
            ComplexBorderSide leftBorder = new ComplexBorderSide(Color.Black, lineWidthInPixels);
            ComplexBorderSide rightBorder = new ComplexBorderSide(Color.Black, lineWidthInPixels);
            ComplexBorderSide topBorder = new ComplexBorderSide(Color.Black, lineWidthInPixels);
            ComplexBorderSide bottomBorder = new ComplexBorderSide(Color.Black, lineWidthInPixels);
            fps.ActiveSheet.Cells[row, col, row2, col2].Border = new ComplexBorder(leftBorder, topBorder, rightBorder, bottomBorder);
            return true;
        }
        #endregion

        #region 设置指定区域简单左边线
        /// <summary>
        /// 设置指定区域简单左边线
        /// </summary>
        /// <param name="fps"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="row2"></param>
        /// <param name="col2"></param>
        /// <param name="lineWidthInPixels"></param>
        /// <returns></returns>
        public static bool setLeftBorderOfCellRange(FpSpread fps, int row, int col, int row2, int col2, int lineWidthInPixels)
        {
            ComplexBorderSide leftBorder = new ComplexBorderSide(Color.Black, lineWidthInPixels);
            fps.ActiveSheet.Cells[row, col, row2, col2].Border = new ComplexBorder(leftBorder, null, null, null);
            return true;
        }
        #endregion

        #region 设置指定区域简单上边线
        /// <summary>
        /// 设置指定区域简单上边线
        /// </summary>
        /// <param name="fps"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="row2"></param>
        /// <param name="col2"></param>
        /// <param name="lineWidthInPixels"></param>
        /// <returns></returns>
        public static bool setTopBorderOfCellRange(FpSpread fps, int row, int col, int row2, int col2, int lineWidthInPixels)
        {
            ComplexBorderSide TopBorder = new ComplexBorderSide(Color.Black, lineWidthInPixels);
            fps.ActiveSheet.Cells[row, col, row2, col2].Border = new ComplexBorder(null, TopBorder, null, null);
            return true;
        }
        #endregion

        #region 设置指定区域简单右边线
        /// <summary>
        /// 设置指定区域简单右边线
        /// </summary>
        /// <param name="fps"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="row2"></param>
        /// <param name="col2"></param>
        /// <param name="lineWidthInPixels"></param>
        /// <returns></returns>
        public static bool setRightBorderOfCellRange(FpSpread fps, int row, int col, int row2, int col2, int lineWidthInPixels)
        {
            ComplexBorderSide rightBorder = new ComplexBorderSide(Color.Black, lineWidthInPixels);
            fps.ActiveSheet.Cells[row, col, row2, col2].Border = new ComplexBorder(null, null, rightBorder, null);
            return true;
        }
        #endregion

        #region 设置指定区域简单下边线
        /// <summary>
        /// 设置指定区域简单下边线
        /// </summary>
        /// <param name="fps"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="row2"></param>
        /// <param name="col2"></param>
        /// <param name="lineWidthInPixels"></param>
        /// <returns></returns>
        public static bool setBottomBorderOfCellRange(FpSpread fps, int row, int col, int row2, int col2, int lineWidthInPixels)
        {
            ComplexBorderSide bottomBorder = new ComplexBorderSide(Color.Black, lineWidthInPixels);
            fps.ActiveSheet.Cells[row, col, row2, col2].Border = new ComplexBorder(null, null, null, bottomBorder);
            return true;
        }
        #endregion

        #region 设置指定单元格标签

        /// <summary>
        /// 设置指定单元格标签
        /// </summary>
        /// <param name="fps"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="tag"></param>
        /// <returns></returns>
        public static bool setCellTag(FpSpread fps, int row, int col, string tag)
        {
            fps.ActiveSheet.Models.Data.SetTag(row, col, tag);
            return true;
        }

        #endregion

        #region 得到指定单元格标签

        /// <summary>
        /// 得到指定单元格标签
        /// </summary>
        /// <param name="fps"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="tag"></param>
        /// <returns></returns>
        public static bool getCellTag(FpSpread fps, int row, int col)
        {
            fps.ActiveSheet.Models.Data.GetTag(row,col);
            return true;
        }

        #endregion

        private SpreadHelper() { }

        /// <summary>
        /// 通过单元格名称返回当前列号
        /// </summary>
        /// <param name="CellName">单元格名称</param>
        /// <returns></returns>
        public static int getColumnNum(string CellName)
        {
            int retVal = 0;
            string rowNum = "";
            Regex r = new Regex(@"[a-zA-Z]+");
            Match m = r.Match(CellName);
            rowNum = m.Value.ToUpper();

            char[] ch = rowNum.ToCharArray();
            for (int i = 0; i < rowNum.Length; i++)
            {
                retVal += ((ch[i] - 'A') + 1) * (int)Math.Pow(26, rowNum.Length - 1 - i);
            }

            retVal = retVal - 1;
            return retVal;

        }

        /// <summary>
        /// 通过单元格名称返回当前行号
        /// </summary>
        /// <param name="CellName">单元格名称</param>
        /// <returns></returns>
        public static int getRowNum(string CellName)
        {
            int retVal = 0;
            Regex r = new Regex(@"[0-9]+");
            Match m = r.Match(CellName);
            retVal = int.Parse(m.Value) - 1;
            return retVal;
        }


        /// <summary>
        /// 没有使用
        /// </summary>
        /// <param name="CellName"></param>
        /// <returns></returns>
        public static int[] GetCellID(string CellName)
        {
            int[] retVal = new int[2];
            string rowNum = "";
            Regex rRow = new Regex(@"[a-zA-Z]+");
            Match mRow = rRow.Match(CellName);
            rowNum = mRow.Value.ToUpper();

            char[] ch = rowNum.ToCharArray();
            for (int i = 0; i < rowNum.Length; i++)
            {
                retVal[0] += ((ch[i] - 'A') + 1) * (int)Math.Pow(26, rowNum.Length - 1 - i);
            }
            retVal[0] = retVal[0] - 1;

            Regex rCol = new Regex(@"[0-9]+");
            Match mCol = rCol.Match(CellName);
            retVal[1] = int.Parse(mCol.Value.ToString()) - 1;
            return retVal;
        }


        //public static bool addSheets(FpSpread fps, int numOfSheets, int startingNumberOfColumns, int startingNumberOfRows, bool protectionLikeExcelTF, Color sheetBackColor, HeaderAutoText rowHeaderAutoText, HeaderAutoText ColumnHeaderAutoText) 
        //{
        //    //'Adds a Sheet for Each Question and Sets the number of Rows and Column
        //    int x, y, z;
        //    fps.Sheets.Count = 0;
        //    //'Create the Sheets
        //    for int x=0,
        //}

        //Public Function AddSheets(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal NumberOfSheets As Integer, ByVal StartingNumberOfColumns As Integer, ByVal StartingNumberOfRows As Integer, ByVal ProtectionLikeExcelTF As Boolean, ByVal SheetBackColor As System.Drawing.Color, ByVal RowHeaderAutoText As FarPoint.Win.Spread.HeaderAutoText, ByVal ColumnHeaderAutoText As FarPoint.Win.Spread.HeaderAutoText) As Boolean

        //Dim x As Integer
        //Dim y As Integer
        //Dim z As Integer
        //SSControlToUse.Sheets.Count = 0
        //'Create the Sheets
        //For x = 0 To NumberOfSheets
        //Dim s As New FarPoint.Win.Spread.SheetView
        //s.ColumnCount = StartingNumberOfColumns
        //s.RowCount = StartingNumberOfRows
        //SSControlToUse.Sheets.Add(s)
        //Dim info As New FarPoint.Win.Spread.StyleInfo
        //'Set the BackColor
        //info.BackColor = SheetBackColor
        //SSControlToUse.Sheets(SSControlToUse.Sheets.Count - 1).DefaultStyle = info
        //'Set Protection Scheme to be like Excels for each sheet
        //For y = 0 To (StartingNumberOfRows - 1)
        //For z = 0 To (StartingNumberOfColumns - 1)
        //s.Cells(y, z).Locked = ProtectionLikeExcelTF
        //Next z
        //Next y
        //SSControlToUse.Sheets(x).RowHeaderAutoText = RowHeaderAutoText
        //SSControlToUse.Sheets(x).ColumnHeaderAutoText = ColumnHeaderAutoText
        //Next x
        //AddSheets = True
        //End Function 'AddSheets


        //Public Function AddSingleSheet(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal StartingNumberOfColumns As Integer, ByVal StartingNumberOfRows As Integer, ByVal ProtectionLikeExcelTF As Boolean, ByVal SheetBackColor As System.Drawing.Color, ByVal RowHeaderAutoText As FarPoint.Win.Spread.HeaderAutoText, ByVal ColumnHeaderAutoText As FarPoint.Win.Spread.HeaderAutoText) As Boolean
        //'Adds a Sheet for Each Question and Sets the number of Rows and Column
        //Dim x As Integer
        //Dim y As Integer
        //'Create the Sheets
        //Dim s As New FarPoint.Win.Spread.SheetView
        //s.ColumnCount = StartingNumberOfColumns
        //s.RowCount = StartingNumberOfRows
        //SSControlToUse.Sheets.Add(s)
        //Dim info As New FarPoint.Win.Spread.StyleInfo
        //'Set the BackColor
        //info.BackColor = SheetBackColor
        //SSControlToUse.Sheets(SSControlToUse.Sheets.Count - 1).DefaultStyle = info
        //'Set Protection Scheme to be like Excels for each sheet
        //For x = 0 To (StartingNumberOfRows - 1)
        //For y = 0 To (StartingNumberOfColumns - 1)
        //s.Cells(x, y).Locked = ProtectionLikeExcelTF
        //Next y
        //Next x
        //SSControlToUse.Sheets(SSControlToUse.Sheets.Count - 1).RowHeaderAutoText = RowHeaderAutoText
        //SSControlToUse.Sheets(SSControlToUse.Sheets.Count - 1).ColumnHeaderAutoText = ColumnHeaderAutoText
        //SSControlToUse.Sheets(SSControlToUse.Sheets.Count - 1).GrayAreaBackColor = Color.SlateGray
        //' Set operation mode and let users select multiple blocks of cells 
        //SSControlToUse.Sheets(SSControlToUse.Sheets.Count - 1).OperationMode = FarPoint.Win.Spread.OperationMode.Normal
        //SSControlToUse.Sheets(SSControlToUse.Sheets.Count - 1).SelectionPolicy = FarPoint.Win.Spread.Model.SelectionPolicy.MultiRange
        //AddSingleSheet = True
        //End Function 'AddSingleSheet


        //Public Function SSControlGlobals(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal EditModePermanentEntireWorkBookTF As Boolean, ByVal AllowCellOverFlowEntireWorkBookTF As Boolean, ByVal ControlsTabStripPolicy As FarPoint.Win.Spread.TabStripPolicy, ByVal TabStripPercentToShow As Single) As Boolean
        //' Set the sheet tabs policy
        //SSControlToUse.TabStripPolicy = ControlsTabStripPolicy
        //' Set the Tab Strip width to: .??
        //SSControlToUse.TabStripRatio = TabStripPercentToShow
        //'Eliminate the focus rectangle for the ENTIRE Control
        //SSControlToUse.EditModePermanent = EditModePermanentEntireWorkBookTF
        //'Allow Cell Text Overflow for the ENTIRE Control
        //SSControlToUse.AllowCellOverflow = AllowCellOverFlowEntireWorkBookTF

        //SSControlToUse.SelectionBlockOptions = FarPoint.Win.Spread.SelectionBlockOptions.Cells


        //End Function


        //Public Function TurnProtectionOnOffForAllSheetsInControl(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal TurnProtectionOn As Boolean) As Boolean
        //Dim x As Integer
        //Dim NumberOfSheets As Int16 = SSControlToUse.Sheets.Count

        //For x = 0 To NumberOfSheets - 1
        //SSControlToUse.Sheets(x).Protect = TurnProtectionOn
        //Next x
        //End Function


        //Public Function SetFont(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal Row As Integer, ByVal Col As Integer, ByVal Row2 As Integer, ByVal Col2 As Integer, ByVal FontFamily As String, ByVal FontSize As Integer, ByRef FontStyle As FontStyle) As Boolean
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).Font = New Font(FontFamily, FontSize, FontStyle)
        //SetFont = True
        //End Function 'SetFontBold


        //Public Function SetCellSpan(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal StartRow As Integer, ByVal StartCol As Integer, ByVal RowsToSpanCount As Integer, ByVal ColsToSpanCount As Integer) As Boolean
        //SSControlToUse.ActiveSheet.AddSpanCell(StartRow, StartCol, RowsToSpanCount, ColsToSpanCount)
        //SetCellSpan = True
        //End Function 'SetCellSpan


        //Public Function SetCellTypeTextForRange(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal Row As Integer, ByVal Col As Integer, ByVal Row2 As Integer, ByVal Col2 As Integer, ByVal MultilineTF As Boolean, ByVal WordWrapTF As Boolean, ByVal ReadOnlyTF As Boolean, ByVal TypeOfScrollBars As System.Windows.Forms.ScrollBars, ByVal MaximumNumberOfCharacters As Int16, ByVal IsLockWhenProtected As Boolean) As Boolean
        //Dim ct As New FarPoint.Win.Spread.CellType.TextCellType
        //ct.Multiline = MultilineTF
        //ct.WordWrap = WordWrapTF
        //ct.ReadOnly = ReadOnlyTF
        //ct.ScrollBars = TypeOfScrollBars
        //ct.MaxLength = MaximumNumberOfCharacters
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).CellType = ct
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).Locked = IsLockWhenProtected
        //SetCellTypeTextForRange = True
        //End Function 'SetCellTypeTextForRange

        //Public Function SetCellTypeGeneralForRange(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal Row As Integer, ByVal Col As Integer, ByVal Row2 As Integer, ByVal Col2 As Integer, ByVal WordWrapTF As Boolean, ByVal IsLockWhenProtected As Boolean) As Boolean
        //Dim ct As New FarPoint.Win.Spread.CellType.GeneralCellType
        //ct.WordWrap = WordWrapTF
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).CellType = ct
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).Locked = IsLockWhenProtected
        //SetCellTypeGeneralForRange = True
        //End Function 'SetCellTypeGeneralForRange

        //Public Function SetCellTypeButtonForRange(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal Row As Integer, ByVal Col As Integer, ByVal Row2 As Integer, ByVal Col2 As Integer, ByVal ButtonColor As Color, ByVal ButtonText As String, ByVal ButtonTextColor As Color, ByVal WordWrapTF As Boolean, ByVal IsLockWhenProtected As Boolean) As Boolean
        //Dim ct As New FarPoint.Win.Spread.CellType.ButtonCellType
        //ct.ButtonColor = ButtonColor
        //ct.Text = ButtonText
        //ct.TextColor = ButtonTextColor
        //ct.WordWrap = WordWrapTF
        //ct.TwoState = False
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).CellType = ct
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).Locked = IsLockWhenProtected
        //SetCellTypeButtonForRange = True
        //End Function 'SetCellTypeButtonForRange


        //Public Function SetCellTypeRadioButtonForRange(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal Row As Integer, ByVal Col As Integer, ByVal Row2 As Integer, ByVal Col2 As Integer, ByVal RadioButtonItemsTextVBTabbed As String, ByVal RadioBtnOrientation As FarPoint.Win.RadioOrientation, ByVal FontFamily As String, ByVal FontSize As Integer, ByRef FontStyle As FontStyle, ByVal IsLockWhenProtected As Boolean) As Boolean
        //Dim ct As New FarPoint.Win.Spread.CellType.MultiOptionCellType
        //'MUST Send In Item List as vbTab separated text
        //Dim ItemList() As String = Split(RadioButtonItemsTextVBTabbed, vbTab)
        //ct.Items = ItemList
        //ct.Orientation = RadioBtnOrientation
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).CellType = ct
        //'SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).BackColor = RadioBtnBackColor
        //'SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).BackColor = RadioBtnForeColor
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).Font = New Font(FontFamily, FontSize, FontStyle)
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).Locked = IsLockWhenProtected
        //SetCellTypeRadioButtonForRange = True
        //End Function 'SetCellTypeRadioButtonForRange

        //Public Function SetCellTypeCheckBoxForRange(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal Row As Integer, ByVal Col As Integer, ByVal Row2 As Integer, ByVal Col2 As Integer, ByVal ChkBoxTextAlgnment As FarPoint.Win.ButtonTextAlign, ByVal ChkBoxTextIfTrue As String, ByVal ChkBoxTextIfFalse As String, ByVal ChkBoxBackColor As Color, ByVal ChkBoxForeColor As Color, ByVal FontFamily As String, ByVal FontSize As Integer, ByRef FontStyle As FontStyle, ByVal IsLockWhenProtected As Boolean) As Boolean
        //Dim ct As New FarPoint.Win.Spread.CellType.CheckBoxCellType
        //ct.TextAlign = ChkBoxTextAlgnment
        //ct.TextTrue = ChkBoxTextIfTrue
        //ct.TextFalse = ChkBoxTextIfFalse
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).CellType = ct
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).BackColor = ChkBoxBackColor
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).ForeColor = ChkBoxForeColor
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).Font = New Font(FontFamily, FontSize, FontStyle)
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).Locked = IsLockWhenProtected
        //SetCellTypeCheckBoxForRange = True
        //End Function 'SetCellTypeCheckBoxForRange


        //Public Function SetCellTypeComboBoxForRange(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal Row As Integer, ByVal Col As Integer, ByVal Row2 As Integer, ByVal Col2 As Integer, ByVal ComboTextEditable As Boolean, ByVal ComboBoxItemsTextVBTabbed As String, ByVal ComboListAlignment As FarPoint.Win.ListAlignment, ByVal PixelsToOffsetListFromAttachedCell As Integer, ByVal ListWidthInPixels As Integer, ByVal NumbeofItemsToDisplayInDropdown As Integer, ByVal MaxLengthOfCharactersToDisplayInCell As Integer, ByVal ComboBoxBackColor As Color, ByVal ComboBoxForeColor As Color, ByVal FontFamily As String, ByVal FontSize As Integer, ByRef FontStyle As FontStyle, ByVal IsLockWhenProtected As Boolean) As Boolean
        //'MUST Send In Item List as vbTab separated text
        //Dim ct As New FarPoint.Win.Spread.CellType.ComboBoxCellType
        //'MUST Send In Item List as vbTab separated text
        //Dim ItemList() As String = Split(ComboBoxItemsTextVBTabbed, vbTab)
        //ct.Editable = ComboTextEditable
        //ct.Items = ItemList
        //ct.ListAlignment = ComboListAlignment
        //ct.ListOffset = PixelsToOffsetListFromAttachedCell
        //ct.ListWidth = ListWidthInPixels
        //ct.MaxDrop = NumbeofItemsToDisplayInDropdown
        //ct.MaxLength = MaxLengthOfCharactersToDisplayInCell
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).CellType = ct
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).BackColor = ComboBoxBackColor
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).ForeColor = ComboBoxForeColor
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).Font = New Font(FontFamily, FontSize, FontStyle)
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).Locked = IsLockWhenProtected
        //SetCellTypeComboBoxForRange = True
        //End Function 'SetCellTypeComboBoxForRange


        //Public Function SetCellTypeComboBoxForRangeFor1DArray(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal Row As Integer, ByVal Col As Integer, ByVal Row2 As Integer, ByVal Col2 As Integer, ByVal ComboTextEditable As Boolean, ByVal ComboBoxItemsText1DArray As String(), ByVal ComboListAlignment As FarPoint.Win.ListAlignment, ByVal PixelsToOffsetListFromAttachedCell As Integer, ByVal ListWidthInPixels As Integer, ByVal NumbeofItemsToDisplayInDropdown As Integer, ByVal MaxLengthOfCharactersToDisplayInCell As Integer, ByVal ComboBoxBackColor As Color, ByVal ComboBoxForeColor As Color, ByVal FontFamily As String, ByVal FontSize As Integer, ByRef FontStyle As FontStyle, ByVal IsLockWhenProtected As Boolean) As Boolean
        //Dim ct As New FarPoint.Win.Spread.CellType.ComboBoxCellType
        //ct.Editable = ComboTextEditable
        //ct.Items = ComboBoxItemsText1DArray
        //ct.ListAlignment = ComboListAlignment
        //ct.ListOffset = PixelsToOffsetListFromAttachedCell
        //ct.ListWidth = ListWidthInPixels
        //ct.MaxDrop = NumbeofItemsToDisplayInDropdown
        //ct.MaxLength = MaxLengthOfCharactersToDisplayInCell
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).CellType = ct
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).BackColor = ComboBoxBackColor
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).ForeColor = ComboBoxForeColor
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).Font = New Font(FontFamily, FontSize, FontStyle)
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).Locked = IsLockWhenProtected
        //SetCellTypeComboBoxForRangeFor1DArray = True
        //End Function 'SetCellTypeComboBoxForRangeFor1DArray


        //Public Function SetCellTypeMaskForRange(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal Row As Integer, ByVal Col As Integer, ByVal Row2 As Integer, ByVal Col2 As Integer, ByVal Mask As String, ByVal IsLockWhenProtected As Boolean) As Boolean
        //Dim maskcell As New FarPoint.Win.Spread.CellType.MaskCellType
        //maskcell.Mask = Mask
        //'maskcell.StringTrim = StringTrimming.Character
        //'maskcell.MaskChar = ""
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).CellType = maskcell
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).Locked = IsLockWhenProtected
        //SetCellTypeMaskForRange = True
        //End Function 'SetCellTypeMaskForRange


        //Public Function SetCellTypeNumberForRange(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal Row As Integer, ByVal Col As Integer, ByVal Row2 As Integer, ByVal Col2 As Integer, ByVal DecimalSeparator As String, ByVal DecimalPlaces As Integer, ByVal LeadingZero As FarPoint.Win.Spread.CellType.LeadingZero, ByVal MaximumValue As Double, ByVal MinimumValue As Double, ByVal IsLockWhenProtected As Boolean) As Boolean
        //Dim nmbrcell As New FarPoint.Win.Spread.CellType.NumberCellType
        //nmbrcell.DecimalSeparator = DecimalSeparator
        //nmbrcell.DecimalPlaces = DecimalPlaces
        //nmbrcell.LeadingZero = LeadingZero ' FarPoint.Win.Spread.CellType.LeadingZero.UseRegional
        //nmbrcell.MaximumValue = MaximumValue
        //nmbrcell.MinimumValue = MinimumValue
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).CellType = nmbrcell
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).Locked = IsLockWhenProtected
        //SetCellTypeNumberForRange = True
        //End Function 'SetCellTypeNumberForRange


        //Public Function SetRowHeaderText(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal Row As Integer, ByVal HorizontalAlignment As FarPoint.Win.spread.CellHorizontalAlignment, ByVal VerticalAlignment As FarPoint.Win.spread.CellVerticalAlignment, ByVal FontFamily As String, ByVal FontSize As Integer, ByRef FontStyle As FontStyle, ByVal LabelText As String) As Boolean
        //SSControlToUse.ActiveSheet.RowHeader.Rows(Row).HorizontalAlignment = HorizontalAlignment
        //SSControlToUse.ActiveSheet.RowHeader.Rows(Row).VerticalAlignment = VerticalAlignment
        //SSControlToUse.ActiveSheet.RowHeader.Rows(Row).Font = New Font(FontFamily, FontSize, FontStyle)
        //SSControlToUse.ActiveSheet.RowHeader.Rows(Row).Label = LabelText
        //SetRowHeaderText = True
        //End Function 'SetRowHeaderText


        //Public Function SetRowHeaderColumnCount(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal ColumnCount As Integer) As Boolean
        //Dim r As FarPoint.Win.Spread.RowHeader
        //r = SSControlToUse.ActiveSheet.RowHeader
        //r.ColumnCount = ColumnCount
        //SetRowHeaderColumnCount = True
        //End Function 'SetRowHeaderColumnCount


        //Public Function SetRowHeaderBackColor(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal RowStart As Integer, ByVal ColumnStartWithinHeader As Integer, ByVal RowEnd As Integer, ByVal ColumnEndWithinHeader As Integer, ByVal BackColor As System.Drawing.Color) As Boolean
        //Dim rh As FarPoint.Win.Spread.RowHeader
        //rh = SSControlToUse.ActiveSheet.RowHeader
        //rh.Cells(RowStart, ColumnStartWithinHeader, RowEnd, ColumnEndWithinHeader).BackColor = BackColor
        //SetRowHeaderBackColor = True
        //End Function 'SetRowHeaderBackColor


        //Public Function SetSpecialRowHeaderText(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal RowStart As Integer, ByVal ColumnStartWithinHeader As Integer, ByVal RowEnd As Integer, ByVal ColumnEndWithinHeader As Integer, ByVal HorizontalAlignment As FarPoint.Win.Spread.CellHorizontalAlignment, ByVal VerticalAlignment As FarPoint.Win.Spread.CellVerticalAlignment, ByVal FontFamily As String, ByVal FontSize As Integer, ByRef FontStyle As FontStyle, ByVal BackColor As System.Drawing.Color, ByVal foreColor As System.Drawing.Color, ByVal TheText As String) As Boolean
        //Dim rh As FarPoint.Win.Spread.RowHeader
        //rh = SSControlToUse.ActiveSheet.RowHeader
        //rh.Cells(RowStart, ColumnStartWithinHeader, RowEnd, ColumnEndWithinHeader).HorizontalAlignment = HorizontalAlignment
        //rh.Cells(RowStart, ColumnStartWithinHeader, RowEnd, ColumnEndWithinHeader).VerticalAlignment = VerticalAlignment
        //rh.Cells(RowStart, ColumnStartWithinHeader, RowEnd, ColumnEndWithinHeader).Font = New Font(FontFamily, FontSize, FontStyle)
        //rh.Cells(RowStart, ColumnStartWithinHeader, RowEnd, ColumnEndWithinHeader).BackColor = BackColor
        //rh.Cells(RowStart, ColumnStartWithinHeader, RowEnd, ColumnEndWithinHeader).ForeColor = foreColor
        //rh.Cells(RowStart, ColumnStartWithinHeader, RowEnd, ColumnEndWithinHeader).Text = TheText
        //SetSpecialRowHeaderText = True
        //End Function 'SetSpecialRowHeaderText


        //Public Function SetSpecialColumnHeaderText(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal RowStartWithinHeader As Integer, ByVal ColumnStart As Integer, ByVal RowEndWithinHeader As Integer, ByVal ColumnEnd As Integer, ByVal HorizontalAlignment As FarPoint.Win.Spread.CellHorizontalAlignment, ByVal VerticalAlignment As FarPoint.Win.Spread.CellVerticalAlignment, ByVal FontFamily As String, ByVal FontSize As Integer, ByRef FontStyle As FontStyle, ByVal BackColor As System.Drawing.Color, ByVal foreColor As System.Drawing.Color, ByVal TheText As String) As Boolean
        //Dim ch As FarPoint.Win.Spread.ColumnHeader
        //ch = SSControlToUse.ActiveSheet.ColumnHeader
        //ch.Cells(RowStartWithinHeader, ColumnStart, RowEndWithinHeader, ColumnEnd).HorizontalAlignment = HorizontalAlignment
        //ch.Cells(RowStartWithinHeader, ColumnStart, RowEndWithinHeader, ColumnEnd).VerticalAlignment = VerticalAlignment
        //ch.Cells(RowStartWithinHeader, ColumnStart, RowEndWithinHeader, ColumnEnd).Font = New Font(FontFamily, FontSize, FontStyle)
        //ch.Cells(RowStartWithinHeader, ColumnStart, RowEndWithinHeader, ColumnEnd).BackColor = BackColor
        //ch.Cells(RowStartWithinHeader, ColumnStart, RowEndWithinHeader, ColumnEnd).ForeColor = foreColor
        //ch.Cells(RowStartWithinHeader, ColumnStart, RowEndWithinHeader, ColumnEnd).Text = TheText
        //SetSpecialColumnHeaderText = True
        //End Function 'SetSpecialColumnHeaderText


        //Public Function SetRowHeaderForeColor(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal RowStart As Integer, ByVal ColumnStartWithinHeader As Integer, ByVal RowEnd As Integer, ByVal ColumnEndWithinHeader As Integer, ByVal ForeColor As System.Drawing.Color) As Boolean
        //Dim rh As FarPoint.Win.Spread.RowHeader
        //rh = SSControlToUse.ActiveSheet.RowHeader
        //rh.Cells(RowStart, ColumnStartWithinHeader, RowEnd, ColumnEndWithinHeader).ForeColor = ForeColor
        //SetRowHeaderForeColor = True
        //End Function 'SetRowHeaderBackColor


        //Public Function SetColumnHeaderText(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal Col As Integer, ByVal HorizontalAlignment As FarPoint.Win.spread.CellHorizontalAlignment, ByVal VerticalAlignment As FarPoint.Win.spread.CellVerticalAlignment, ByVal FontFamily As String, ByVal FontSize As Integer, ByRef FontStyle As FontStyle, ByVal LabelText As String) As Boolean
        //SSControlToUse.ActiveSheet.ColumnHeader.Columns(Col).HorizontalAlignment = HorizontalAlignment
        //SSControlToUse.ActiveSheet.ColumnHeader.Columns(Col).VerticalAlignment = VerticalAlignment
        //SSControlToUse.ActiveSheet.ColumnHeader.Columns(Col).Font = New Font(FontFamily, FontSize, FontStyle)
        //SSControlToUse.ActiveSheet.ColumnHeader.Columns(Col).Label = LabelText
        //SetColumnHeaderText = True
        //End Function 'SetColumnHeaderText


        //Public Function SetColumnHeaderRowCount(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal RowCount As Integer) As Boolean
        //Dim r As FarPoint.Win.Spread.ColumnHeader
        //r = SSControlToUse.ActiveSheet.ColumnHeader
        //r.RowCount = RowCount
        //SetColumnHeaderRowCount = True
        //End Function 'SetRowHeaderColumnCount


        //Public Function SetColumnHeaderSpan(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal Row As Integer, ByVal Column As Integer, ByVal RowCount As Integer, ByVal ColumnCount As Integer) As Boolean
        //SSControlToUse.ActiveSheet.AddColumnHeaderSpanCell(Row, Column, RowCount, ColumnCount)
        //End Function


        //Public Function SetColumnHeaderBackColor(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal RowStartWithinHeader As Integer, ByVal ColumnStart As Integer, ByVal RowEndWithinHeader As Integer, ByVal ColumnEnd As Integer, ByVal BackColor As System.Drawing.Color) As Boolean
        //Dim rh As FarPoint.Win.Spread.ColumnHeader
        //rh = SSControlToUse.ActiveSheet.ColumnHeader
        //rh.Cells(RowStartWithinHeader, ColumnStart, RowEndWithinHeader, ColumnEnd).BackColor = BackColor
        //SetColumnHeaderBackColor = True
        //End Function 'SetColumnHeaderBackColor


        //Public Function SetColumnHeaderForeColor(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal RowStartWithinHeader As Integer, ByVal ColumnStart As Integer, ByVal RowEndWithinHeader As Integer, ByVal ColumnEnd As Integer, ByVal ForeColor As System.Drawing.Color) As Boolean
        //Dim rh As FarPoint.Win.Spread.ColumnHeader
        //rh = SSControlToUse.ActiveSheet.ColumnHeader
        //rh.Cells(RowStartWithinHeader, ColumnStart, RowEndWithinHeader, ColumnEnd).ForeColor = ForeColor
        //SetColumnHeaderForeColor = True
        //End Function 'SetColumnHeaderForeColor

        //Public Function ClearComboBoxForRange(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal Row As Integer, ByVal Col As Integer, ByVal Row2 As Integer, ByVal Col2 As Integer) As Boolean
        //Dim ct As New FarPoint.Win.Spread.CellType.ComboBoxCellType
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).CellType = ct
        //ct.Clear()
        //ClearComboBoxForRange = True
        //End Function 'ClearComboBoxForRange


    }
}

New Version

//======================================================================
//
//        Copyright (C) 2007-2008 RaySoft
//        All rights reserved
//        guid1:              4b887cc8-ac8c-4397-bff3-628761c59f48
//        guid2:              80f46765-0f16-44c4-a542-2b7eb38522f7
//        guid3:              923c4a79-98ea-4148-8d1a-e13993a55545
//        guid4:              da27be46-708a-453f-aa4d-25e96d116917
//        guid5:              05158992-6744-44d1-9bcb-cb422e35afbf
//        CLR版本:            2.0.50727.5448
//        新建项输入的名称:   SpreadHelper
//        机器名称:           RAY-PC
//        注册组织名:         
//        命名空间名称:       Ray.Spread
//        文件名:             SpreadHelper
//        当前系统时间:       2013/07/24
//        当前登录用户名:     Administrator
//        创建年份:           2013
//
//======================================================================

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.Text.RegularExpressions;

using FarPoint.Win;
using FarPoint.Win.Spread;
using FarPoint.Win.Spread.Model;
using FarPoint.Win.Spread.Design;

namespace Ray.Spread
{
    public class SpreadHelper
    {
        public SpreadHelper() { }

        #region 设置单元格字体
 
        /// <summary>
        /// 设置单元格字体名称
        /// </summary>
        /// <param name="fpSpread" >表格控件</param>
        /// <param name="cellRange">范围</param>
        /// <param name="FontName">字体名称</param>
        public static void SetFontFamilyForRange(FpSpread fpSpread, CellRange[] cellRanges, string FontName)
        {
            foreach (CellRange cellRange in cellRanges)
            {
                for (int row = cellRange.Row; row < cellRange.Row + cellRange.RowCount; row++)
                {
                    for (int column = cellRange.Column; column < cellRange.Column + cellRange.ColumnCount; column++)
                    {
                        Font font = fpSpread.ActiveSheet.Cells[row, column].Font == null ? fpSpread.ActiveSheet.DefaultStyle.Font : fpSpread.ActiveSheet.Cells[row, column].Font;
                        fpSpread.ActiveSheet.Cells[row, column].Font = new Font(FontName, font.Size, font.Style);
                    }
                }
            }
        }

        /// <summary>
        /// 设置单元格字体大小
        /// </summary>
        /// <param name="fpSpread" >表格控件</param>
        /// <param name="cellRange">范围</param>
        /// <param name="FontSize">字体大小</param>
        public static void SetFontSizeForRange(FpSpread fpSpread, CellRange[] cellRanges, float fontSize)
        {
            foreach (CellRange cellRange in cellRanges)
            {
                for (int row = cellRange.Row; row < cellRange.Row + cellRange.RowCount; row++)
                {
                    for (int column = cellRange.Column; column < cellRange.Column + cellRange.ColumnCount; column++)
                    {
                        Font font = fpSpread.ActiveSheet.Cells[row, column].Font == null ? fpSpread.ActiveSheet.DefaultStyle.Font : fpSpread.ActiveSheet.Cells[row, column].Font;
                        fpSpread.ActiveSheet.Cells[row, column].Font = new Font(font.FontFamily.Name, fontSize, font.Style);
                    }
                }
            }
        }

        /// <summary>
        /// 设置单元格字体样式
        /// </summary>
        /// <param name="fpSpread" >表格控件</param>
        /// <param name="cellRange">范围</param>
        /// <param name="FontStyle">字休样式</param>
        /// <param name="style" ></param>
        /// <param name="val" ></param>
        public static void SetFontStyleForRange(FpSpread fpSpread, CellRange[] cellRanges,string style, bool val)
        {
            string fs;
            foreach (CellRange cellRange in cellRanges)
            {
                for (int row = cellRange.Row; row < cellRange.Row + cellRange.RowCount; row++)
                {
                    for (int column = cellRange.Column; column < cellRange.Column + cellRange.ColumnCount; column++)
                    {
                        Font font = fpSpread.ActiveSheet.Cells[row, column].Font == null ? fpSpread.ActiveSheet.DefaultStyle.Font : fpSpread.ActiveSheet.Cells[row, column].Font;
                        fs = "";
                        if (style == "Bold")
                        {
                            if (font.Italic)
                            {
                                fs += "Italic,";
                            }
                            if (font.Underline)
                            {
                                fs += "Underline,";
                            }
                            if (font.Strikeout)
                            {
                                fs += "Strikeout,";
                            }
                            if (val == true)
                            {
                                fs += "Bold,";
                            }
                        }
                        else if (style == "Italic")
                        {
                            if (font.Bold)
                            {
                                fs += "Bold,";
                            }
                            if (font.Underline)
                            {
                                fs += "Underline,";
                            }
                            if (font.Strikeout)
                            {
                                fs += "Strikeout,";
                            }
                            if (val == true)
                            {
                                fs += "Italic,";
                            }
                        }
                        else if (style == "Underline")
                        {
                            if (font.Bold)
                            {
                                fs += "Bold,";
                            }
                            if (font.Italic )
                            {
                                fs += "Italic,";
                            }
                            if (font.Strikeout)
                            {
                                fs += "Strikeout,";
                            }
                            if (val == true)
                            {
                                fs += "Underline,";
                            }
                        }
                        else if (style == "Strikeout")
                        {
                            if (font.Bold)
                            {
                                fs += "Bold,";
                            }
                            if (font.Italic)
                            {
                                fs += "Italic,";
                            }
                            if (font.Underline )
                            {
                                fs += "Underline,";
                            }
                            if (val == true)
                            {
                                fs += "Strikeout,";
                            }
                        }
                        else
                        {  
                        }

                        if (fs.Length > 0)
                        {
                            fpSpread.ActiveSheet.Cells[row, column].Font = new Font(font.FontFamily.Name, font.Size, (FontStyle)Enum.Parse(typeof(FontStyle), fs.Substring(0, fs.Length - 1)));
                        }
                        else
                        {
                            fpSpread.ActiveSheet.Cells[row, column].Font = new Font(font.FontFamily.Name, font.Size, (FontStyle)Enum.Parse(typeof(FontStyle), "Regular"));
                        }
                    }
                }
            }
        }

        /// <summary>
        /// 设置单元格字体样式
        /// </summary>
        /// <param name="fpSpread">表格控件</param>
        /// <param name="cellrange">范围</param>
        /// <param name="fontFamily">字体名称</param>
        /// <param name="fontStyle">字体大小</param>
        /// <param name="fontSize">字休样式</param>
        /// <returns></returns>
        public static void SetFontForRange(FpSpread fpSpread, CellRange[] cellRanges, string fontFamily, FontStyle fontStyle, float fontSize)
        {
            foreach (FarPoint.Win.Spread.Model.CellRange cellRange in cellRanges)
            {
                for (int i = cellRange.Row; i < cellRange.RowCount + cellRange.Row; i++)
                {
                    for (int j = cellRange.Column; j < cellRange.ColumnCount + cellRange.Column; j++)
                    {
                        Font font = new Font(fontFamily, fontSize, fontStyle);
                        fpSpread.ActiveSheet.Cells[i, j].Font = font;
                        
                    }
                }
            }
        }

        #endregion

        #region 设置单元格对齐

        /// <summary>
        /// 设置单元格横向对齐
        /// </summary>
        /// <param name="fpSpread" >表格控件</param>
        /// <param name="cellRange">范围</param>
        /// <param name="horizontalAlignment">横向对齐</param>
        public static void SetHorizontalAlignmentForRange(FpSpread fpSpread, CellRange[] cellRanges, FarPoint.Win.Spread.CellHorizontalAlignment horizontalAlignment)
        {
            foreach (CellRange cellRange in cellRanges)
            {
                for (int row = cellRange.Row; row < cellRange.Row + cellRange.RowCount; row++)
                {
                    for (int column = cellRange.Column; column < cellRange.Column + cellRange.ColumnCount; column++)
                    {
                        fpSpread.ActiveSheet.Cells[row, column].HorizontalAlignment = horizontalAlignment;
                    }
                }
            }
        }
        
        /// <summary>
        /// 设置单元格纵向对齐
        /// </summary>
        /// <param name="fpSpread">表格控件</param>
        /// <param name="cellRange">范围</param>
        /// <param name="verticalAlignment">横向对齐</param>
        public static void SetVerticalAlignmentForRange(FpSpread fpSpread, CellRange[] cellRanges, CellVerticalAlignment verticalAlignment)
        {
            foreach (CellRange cellRange in cellRanges)
            {
                for (int row = cellRange.Row; row < cellRange.Row + cellRange.RowCount; row++)
                {
                    for (int column = cellRange.Column; column < cellRange.Column + cellRange.ColumnCount; column++)
                    {
                        fpSpread.ActiveSheet.Cells[row, column].VerticalAlignment = verticalAlignment;
                    }
                }
            }
        }

        /// <summary>
        /// 设置单元格对齐
        /// </summary>
        /// <param name="fps"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="row2"></param>
        /// <param name="col2"></param>
        /// <param name="HorizontalAlignment"></param>
        /// <param name="VerticalAlignment"></param>
        /// <returns></returns>
        public static void setCellAlignmentForRange(FpSpread fpSpread, int row, int col, int row2, int col2, CellHorizontalAlignment HorizontalAlignment, CellVerticalAlignment VerticalAlignment)
        {
            fpSpread.ActiveSheet.Cells[row, col, row2, col2].HorizontalAlignment = HorizontalAlignment;
            fpSpread.ActiveSheet.Cells[row, col, row2, col2].VerticalAlignment = VerticalAlignment;
        }

        #endregion

        #region 设置单元格表格线

        /// <summary>
        /// 
        /// </summary>
        /// <param name="fps"></param>
        /// <returns></returns>
        public static bool SetBorderOutSideBold(FpSpread fps)
        {
            //停止重绘界面            
            fps.SuspendLayout();

            //得到用户选择区域
            CellRange[] cellRanges = fps.ActiveSheet.GetSelections();
            
            //定义一个边框
            ComplexBorderSide Border = new FarPoint.Win.ComplexBorderSide(Color.Black, 3, System.Drawing.Drawing2D.DashStyle.Solid);

            if (cellRanges != null)
            {
                foreach (CellRange cellRange in cellRanges)
                {
                    if (cellRange.RowCount == 1 && cellRange.ColumnCount == 1)//一个单元格
                    {
                        SetComplexSingeCellBorders(fps, cellRange.Row, cellRange.Column, Border, Border, Border, Border);
                    }
                    else if (cellRange.RowCount == 1)//一行
                    {
                        for (int col = cellRange.Column; col < cellRange.Column + cellRange.ColumnCount; col++)
                        {
                            if (col == cellRange.Column)
                            {
                                SetComplexSingeCellBorders(fps, cellRange.Row, col, Border, Border, null, Border);
                            }
                            else if (col == cellRange.Column + cellRange.ColumnCount - 1)
                            {
                                SetComplexSingeCellBorders(fps, cellRange.Row, col, null, Border, Border, Border);
                            }
                            else
                            {
                                SetComplexSingeCellBorders(fps, cellRange.Row, col, null, Border, null, Border);
                            }
                        }
                    }
                    else if (cellRange.ColumnCount == 1) //一列
                    {
                        for (int row = cellRange.Row; row < cellRange.Row + cellRange.RowCount; row++)
                        {
                            if (row == cellRange.Row)
                            {
                                SetComplexSingeCellBorders(fps, row, cellRange.Column, Border, Border, Border, null);
                            }
                            else if (row == cellRange.Row + cellRange.RowCount - 1)
                            {
                                SetComplexSingeCellBorders(fps, row, cellRange.Column, Border, null, Border, Border);
                            }
                            else
                            {
                                SetComplexSingeCellBorders(fps, row, cellRange.Column, Border, null, Border, null);
                            }
                        }
                    }
                    else//多行多列
                    {
                        //循环设置单元格上边框
                        for (int row = cellRange.Row; row < cellRange.Row + cellRange.RowCount; row++)
                        {
                            for (int col = cellRange.Column; col < cellRange.ColumnCount + cellRange.Column; col++)
                            {
                                if (row == cellRange.Row)//第一行
                                {
                                    if (col == cellRange.Column)//第一列
                                    {
                                        SetComplexSingeCellBorders(fps, row, col, Border, Border, null, null);
                                    }
                                    else if (col == cellRange.Column + cellRange.ColumnCount - 1)//最后一列
                                    {
                                        SetComplexSingeCellBorders(fps, row, col, null, Border, Border, null);
                                    }
                                    else//其它列
                                    {
                                        SetComplexSingeCellBorders(fps, row, col, null, Border, null, null);
                                    }
                                }
                                else if (row == cellRange.Row + cellRange.RowCount - 1)//最后一行
                                {
                                    if (col == cellRange.Column)//第一列
                                    {
                                        SetComplexSingeCellBorders(fps, row, col, Border, null, null, Border);
                                    }
                                    else if (col == cellRange.Column + cellRange.ColumnCount - 1)//最后一列
                                    {
                                        SetComplexSingeCellBorders(fps, row, col, null, null, Border, Border);
                                    }
                                    else//其它列
                                    {
                                        SetComplexSingeCellBorders(fps, row, col, null, null, null, Border);
                                    }
                                }
                                else//其它行
                                {
                                    if (col == cellRange.Column)//第一列
                                    {
                                        SetComplexSingeCellBorders(fps, row, col, Border, null, null, null);
                                    }
                                    else if (col == cellRange.Column + cellRange.ColumnCount - 1)//最后一列
                                    {
                                        SetComplexSingeCellBorders(fps, row, col, null, null, Border, null);
                                    }
                                    else
                                    {

                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                throw new Exception("未能得到用户选择的区域!");
            }
            //恢复重绘界面
            fps.ResumeLayout();

            return true;
        }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="fps"></param>
        /// <returns></returns>
        public static bool SetBorderOutSide(FpSpread fps)
        {
            //停止重绘界面            
            fps.SuspendLayout();

            //得到用户选择区域
            CellRange[] cellRanges = fps.ActiveSheet.GetSelections();
            
            //定义一个边框
            ComplexBorderSide Border = new FarPoint.Win.ComplexBorderSide(Color.Black, 1, System.Drawing.Drawing2D.DashStyle.Solid);

            if (cellRanges != null)
            {
                foreach (CellRange cellRange in cellRanges)
                {
                    if (cellRange.RowCount == 1 && cellRange.ColumnCount == 1)//一个单元格
                    {
                        SetComplexSingeCellBorders(fps, cellRange.Row, cellRange.Column, Border, Border, Border, Border);
                    }
                    else if (cellRange.RowCount == 1)//一行
                    {
                        for (int col = cellRange.Column; col < cellRange.Column + cellRange.ColumnCount; col++)
                        {
                            if (col == cellRange.Column)
                            {
                                SetComplexSingeCellBorders(fps, cellRange.Row, col, Border, Border, null, Border);
                            }
                            else if (col == cellRange.Column + cellRange.ColumnCount - 1)
                            {
                                SetComplexSingeCellBorders(fps, cellRange.Row, col, null, Border, Border, Border);
                            }
                            else
                            {
                                SetComplexSingeCellBorders(fps, cellRange.Row, col, null, Border, null, Border);
                            }
                        }
                    }
                    else if (cellRange.ColumnCount == 1) //一列
                    {
                        for (int row = cellRange.Row; row < cellRange.Row + cellRange.RowCount; row++)
                        {
                            if (row == cellRange.Row)
                            {
                                SetComplexSingeCellBorders(fps, row, cellRange.Column, Border, Border, Border, null);
                            }
                            else if (row == cellRange.Row + cellRange.RowCount - 1)
                            {
                                SetComplexSingeCellBorders(fps, row, cellRange.Column, Border, null, Border, Border);
                            }
                            else
                            {
                                SetComplexSingeCellBorders(fps, row, cellRange.Column, Border, null, Border, null);
                            }
                        }
                    }
                    else//多行多列
                    {
                        //循环设置单元格上边框
                        for (int row = cellRange.Row; row < cellRange.Row + cellRange.RowCount; row++)
                        {
                            for (int col = cellRange.Column; col < cellRange.ColumnCount + cellRange.Column; col++)
                            {
                                if (row == cellRange.Row)//第一行
                                {
                                    if (col == cellRange.Column)//第一列
                                    {
                                        SetComplexSingeCellBorders(fps, row, col, Border, Border, null, null);
                                    }
                                    else if (col == cellRange.Column + cellRange.ColumnCount - 1)//最后一列
                                    {
                                        SetComplexSingeCellBorders(fps, row, col, null, Border, Border, null);
                                    }
                                    else//其它列
                                    {
                                        SetComplexSingeCellBorders(fps, row, col, null, Border, null, null);
                                    }
                                }
                                else if (row == cellRange.Row + cellRange.RowCount - 1)//最后一行
                                {
                                    if (col == cellRange.Column)//第一列
                                    {
                                        SetComplexSingeCellBorders(fps, row, col, Border, null, null, Border);
                                    }
                                    else if (col == cellRange.Column + cellRange.ColumnCount - 1)//最后一列
                                    {
                                        SetComplexSingeCellBorders(fps, row, col, null, null, Border, Border);
                                    }
                                    else//其它列
                                    {
                                        SetComplexSingeCellBorders(fps, row, col, null, null, null, Border);
                                    }
                                }
                                else//其它行
                                {
                                    if (col == cellRange.Column)//第一列
                                    {
                                        SetComplexSingeCellBorders(fps, row, col, Border, null, null, null);
                                    }
                                    else if (col == cellRange.Column + cellRange.ColumnCount - 1)//最后一列
                                    {
                                        SetComplexSingeCellBorders(fps, row, col, null, null, Border, null);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                throw new Exception("未能得到用户选择的区域!");
            }

            //恢复重绘界面
            fps.ResumeLayout();

            return true;

        }

        /// <summary>
        /// 所有边框
        /// </summary>
        /// <param name="fps"></param>
        /// <returns></returns>
        public static bool SetBorderFull(FpSpread fps)
        {
            //停止重绘界面            
            fps.SuspendLayout();

            //得到用户选择区域法
            CellRange[] cellRanges = fps.ActiveSheet.GetSelections();

            //定义一个边框
            ComplexBorderSide Border = new FarPoint.Win.ComplexBorderSide(Color.Black, 1, System.Drawing.Drawing2D.DashStyle.Solid);

            if (cellRanges != null)
            {
                foreach (CellRange cellRange in cellRanges)
                {
                    if (cellRange.RowCount == 1 && cellRange.ColumnCount == 1)//一个单元格
                    {
                        SetComplexSingeCellBorders(fps, cellRange.Row, cellRange.Column, Border, Border, Border, Border);
                    }
                    else if (cellRange.RowCount == 1)//一行
                    {
                        for (int col = cellRange.Column; col < cellRange.Column + cellRange.ColumnCount; col++)
                        {
                            if (col == cellRange.Column)
                            {
                                SetComplexSingeCellBorders(fps, cellRange.Row, cellRange.Column, Border, Border, Border, Border);
                            }
                            else
                            {
                                SetComplexSingeCellBorders(fps, cellRange.Row, col, null, Border, Border, Border);
                            }
                        }
                    }
                    else if (cellRange.ColumnCount == 1) //一列
                    {
                        for (int row = cellRange.Row; row < cellRange.Row + cellRange.RowCount; row++)
                        {
                            if (row == cellRange.Row)
                            {
                                SetComplexSingeCellBorders(fps, cellRange.Row, cellRange.Column, Border, Border, Border, Border);
                            }
                            else
                            {
                                SetComplexSingeCellBorders(fps, row, cellRange.Column, Border, null, Border, Border);
                            }
                        }
                    }
                    else//多行多列
                    {
                        //循环设置单元格上边框
                        for (int row = cellRange.Row; row < cellRange.Row + cellRange.RowCount; row++)
                        {
                            for (int col = cellRange.Column; col < cellRange.ColumnCount + cellRange.Column; col++)
                            {
                                if (row == cellRange.Row && col == cellRange.Column)
                                {
                                    SetComplexSingeCellBorders(fps, row, col, Border, Border, Border, Border);
                                }
                                else if (row == cellRange.Row)//第一行
                                {
                                    SetComplexSingeCellBorders(fps, row, col, null, Border, Border, Border);
                                }
                                else if (col == cellRange.Column)//第一列
                                {
                                    SetComplexSingeCellBorders(fps, row, col, Border, null, Border, Border);
                                }
                                else
                                {
                                    SetComplexSingeCellBorders(fps, row, col, null, null, Border, Border);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                throw new Exception("未能得到用户选择的区域!");
            }

            //恢复重绘界面
            fps.ResumeLayout();

            return true;

        }

        /// <summary>
        /// 无边框
        /// </summary>
        /// <param name="fps"></param>
        /// <returns></returns>
        public static bool SetBorderNone(FpSpread fps)
        {
            //停止重绘界面            
            fps.SuspendLayout();

            //得到用户选择区域
            CellRange[] cellRanges = fps.ActiveSheet.GetSelections();

            if (cellRanges != null)
            {
                foreach (CellRange cellRange in cellRanges)
                {
                    //循环设置单元格上边框
                    for (int row = cellRange.Row; row < cellRange.Row + cellRange.RowCount; row++)
                    {
                        for (int col = cellRange.Column; col < cellRange.ColumnCount + cellRange.Column; col++)
                        {
                            SetComplexSingeCellBorders(fps, row, col, null, null, null, null);
                        }
                    }
                }
            }
            else
            {
                throw new Exception("未能得到用户选择的区域!");
            }

            //恢复重绘界面
            fps.ResumeLayout();

            return true;
        }

        /// <summary>
        /// 设置表格边框
        /// </summary>
        /// <param name="fps"></param>
        /// <param name="cellRanges"></param>
        /// <returns></returns>
        public static bool SetBorderSide(FpSpread fps, BorderStyle borderStyle)
        {
            //停止重绘界面            
            fps.SuspendLayout();

            CellRange[] cellRanges = fps.ActiveSheet.GetSelections();

            if (cellRanges != null)
            {

                foreach (CellRange cellRange in cellRanges)
                {
                    int row0 = cellRange.Row;
                    int row1 = cellRange.Row + cellRange.RowCount;
                    int col0 = cellRange.Column;
                    int col1 = cellRange.Column + cellRange.ColumnCount;

                    switch (borderStyle)
                    {
                        case BorderStyle .Bottom :
                            row0 = cellRange.Row + cellRange.RowCount - 1;
                            break;
                        case BorderStyle.Top:
                            row1 = cellRange.Row + 1;
                            break;
                        case BorderStyle.Right :
                            col0 = cellRange.Column + cellRange.ColumnCount - 1;
                            break;
                        case BorderStyle.Left :
                            col1 = cellRange.Column + 1;
                            break;
                        default:
                            break;
                    }

                    //循环设置单元格边框
                    for (int row = row0; row < row1; row++)
                    {
                        for (int col = col0; col < col1; col++)
                        {
                            //取得单元格边框
                            ComplexBorder border = (FarPoint.Win.ComplexBorder)fps.ActiveSheet.Cells[row, col].Border;
                            ComplexBorderSide topBorder = null;
                            ComplexBorderSide rightBorder = null;
                            ComplexBorderSide bottomBorder = null;
                            ComplexBorderSide leftBorder = null;

                            if (border != null)
                            {
                                if (border.Top.Style.ToString().ToLower() != "none") topBorder = border.Top;
                                if (border.Bottom.Style.ToString().ToLower() != "none") bottomBorder = border.Bottom;
                                if (border.Left.Style.ToString().ToLower() != "none") leftBorder = border.Left;
                                if (border.Right.Style.ToString().ToLower() != "none") rightBorder = border.Right;
                            }


                            //设置要改的单元格边框
                            ComplexBorderSide borderSide = new ComplexBorderSide(Color.Black, 1, System.Drawing.Drawing2D.DashStyle.Solid);

                            switch (borderStyle )
                            {
                                case BorderStyle.Bottom :
                                    bottomBorder = borderSide;
                                    break;
                                case BorderStyle.Top :
                                    topBorder = borderSide;
                                    break;
                                case BorderStyle.Left:
                                    leftBorder = borderSide;
                                    break;
                                case BorderStyle.Right :
                                    rightBorder = borderSide;
                                    break;
                                default:
                                    throw new Exception("边框参数错误!");
                            }
                            SetComplexSingeCellBorders(fps, row, col, leftBorder, topBorder, rightBorder, bottomBorder);
                        }
                    }
                }
            }
            else
            {
                throw new Exception("未能得到用户选择的区域!");
            }
            
            //恢复重绘界面
            fps.ResumeLayout();

            return true;
        }

        /// <summary>
        /// 打开边框编辑器
        /// </summary>
        /// <param name="fps"></param>
        /// <returns></returns>
        public static bool ShowBorderEditor(FpSpread fps)
        {
            fps.SuspendLayout();

            FarPoint.Win.Spread.Design.BorderEditor borderedit = new FarPoint.Win.Spread.Design.BorderEditor(fps);
            borderedit.Name = "边框设置";
            if (fps.ActiveSheet.SelectionCount == 0)
            {
                borderedit.StartColumn = fps.ActiveSheet.ActiveColumnIndex;
                borderedit.ColumnCount = 1;
                borderedit.StartRow = fps.ActiveSheet.ActiveRowIndex;
                borderedit.RowCount = 1;
            }
            else
            {
                FarPoint.Win.Spread.Model.CellRange range = fps.ActiveSheet.GetSelection(0);   //选中区域
                borderedit.StartColumn = range.Column;
                borderedit.ColumnCount = range.ColumnCount;
                borderedit.StartRow = range.Row;
                borderedit.RowCount = range.RowCount;
            }
            borderedit.ShowDialog();

            fps.ResumeLayout();
            return true;
        }
        
        /// <summary>
        /// 设置单元格表格线
        /// </summary>
        /// <param name="fps"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="leftBorder"></param>
        /// <param name="topBorder"></param>
        /// <param name="rightBorder"></param>
        /// <param name="bottomBorder"></param>
        /// <returns></returns>
        public static bool SetComplexSingeCellBorders(FpSpread fps, int row, int col, FarPoint.Win.ComplexBorderSide leftBorder, FarPoint.Win.ComplexBorderSide topBorder, FarPoint.Win.ComplexBorderSide rightBorder, FarPoint.Win.ComplexBorderSide bottomBorder)
        {
            if (leftBorder != null & topBorder == null & rightBorder == null & bottomBorder == null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(leftBorder, null, null, null);
            }//Left
            else if (leftBorder == null & topBorder != null & rightBorder == null & bottomBorder == null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(null, topBorder, null, null);
            }//Top
            else if (leftBorder == null & topBorder == null & rightBorder != null & bottomBorder == null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(null, null, rightBorder, null);
            }//Right
            else if (leftBorder == null & topBorder == null & rightBorder == null & bottomBorder != null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(null, null, null, bottomBorder);
            }//Bottom
            else if (leftBorder != null & topBorder != null & rightBorder == null & bottomBorder == null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(leftBorder, topBorder, null, null);
            }//Left + Top
            else if (leftBorder != null & topBorder == null & rightBorder != null & bottomBorder == null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(leftBorder, null, rightBorder, null);
            }//Left + Right
            else if (leftBorder != null & topBorder == null & rightBorder == null & bottomBorder != null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(leftBorder, null, null, bottomBorder);
            }//Left + Bottom
            else if (leftBorder == null & topBorder != null & rightBorder != null & bottomBorder == null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(null, topBorder, rightBorder, null);
            }//Top + Right
            else if (leftBorder == null & topBorder != null & rightBorder == null & bottomBorder != null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(null, topBorder, null, bottomBorder);
            }//Top + Bottom
            else if (leftBorder == null & topBorder == null & rightBorder != null & bottomBorder != null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(null, null, rightBorder, bottomBorder);
            }//Right + Bottom
            else if (leftBorder != null & topBorder != null & rightBorder != null & bottomBorder == null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(leftBorder, topBorder, rightBorder, null);
            }//Left + Top + Right
            else if (leftBorder != null & topBorder != null & rightBorder == null & bottomBorder != null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(leftBorder, topBorder, null, bottomBorder);
            }//Left + Top + Bottom
            else if (leftBorder != null & topBorder == null & rightBorder != null & bottomBorder != null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(leftBorder, null,rightBorder , bottomBorder);
            }//Left + Right + Bottom
            else if (leftBorder == null & topBorder != null & rightBorder != null & bottomBorder != null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(null, topBorder, rightBorder, bottomBorder);
            }//Top + Right + Bottom 原版中没有这一项.
            else if (leftBorder != null & topBorder != null & rightBorder == null & bottomBorder != null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(leftBorder , topBorder, null, bottomBorder);
            }//Top + left + Bottom 原版中没有这一项.
            else if (leftBorder != null & topBorder != null & rightBorder != null & bottomBorder != null)
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(leftBorder, topBorder, leftBorder, bottomBorder);
            }//Left + Top + Right + Bottom
            else
            {
                fps.ActiveSheet.Cells[row, col].Border = new FarPoint.Win.ComplexBorder(null, null, null, null);
            }//All Null
            return true;
        }

        #endregion

        #region 清除表格线
        /// <summary>
        /// 清除表格线
        /// </summary>
        /// <param name="fps"></param>
        /// <returns></returns>
        public static bool ClearAllCellBoders(FpSpread fps)
        {
            fps.ActiveSheet.HorizontalGridLine = new GridLine(FarPoint.Win.Spread.GridLineType.None);
            fps.ActiveSheet.VerticalGridLine = new GridLine(FarPoint.Win.Spread.GridLineType.None);
            return true;
        }
        #endregion

        #region 设置单元格的值

        /// <summary>
        /// 设置单元格的值
        /// </summary>
        /// <param name="fps"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="textVal"></param>
        /// <returns></returns>
        public static bool setValue(FpSpread fps, int row, int col, string textVal)
        {
            fps.ActiveSheet.SetValue(row, col, textVal);
            return true;
        }

        #endregion

        #region 设置单元格背景颜色

        /// <summary>
        /// 设置单元格背景颜色
        /// </summary>
        /// <param name="fps"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="row2"></param>
        /// <param name="col2"></param>
        /// <param name="theBackColor"></param>
        /// <returns></returns>
        public static bool setBackColorForRange(FpSpread fps, int row, int col, int row2, int col2, Color theBackColor)
        {
            fps.ActiveSheet.Cells[row, col, row2, col2].BackColor = theBackColor;
            return true;
        }

        #endregion

        #region 设置单元格前景颜色

        /// <summary>
        /// 设置单元格前景颜色
        /// </summary>
        /// <param name="fps"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="row2"></param>
        /// <param name="col2"></param>
        /// <param name="theForceColor"></param>
        /// <returns></returns>
        public static bool setForceColorForRange(FpSpread fps, int row, int col, int row2, int col2, Color theForceColor)
        {
            fps.ActiveSheet.Cells[row, col, row2, col2].ForeColor = theForceColor;
            return true;
        }

        #endregion

        #region 设置单元格文本
        /// <summary>
        /// 设置单元格的文本
        /// </summary>
        /// <param name="fps"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="sText"></param>
        /// <returns></returns>
        public static bool setText(FpSpread fps, int row, int col, string sText)
        {
            fps.ActiveSheet.SetValue(row, col, sText);
            return true;
        }
        #endregion

        #region 设置指定行行高

        public static bool setRowHeightForRange(FpSpread fps, int row, int col, int row2, int col2, Single rowHeightInPixels)
        {
            fps.ActiveSheet.Cells[row, col, row2, col2].Row.Height = rowHeightInPixels;
            return true;
        }
        #endregion

        #region 设置指定列列宽

        public static bool setColumnWidthForRange(FpSpread fps, int row, int col, int row2, int col2, Single columnWidthInPixels)
        {
            fps.ActiveSheet.Cells[row, col, row2, col2].Column.Width = columnWidthInPixels;
            return true;
        }
        #endregion

        #region 设置单元格简单表格线
        /// <summary>
        /// 设置单元格简单表格线
        /// </summary>
        /// <param name="fps"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="lineWidthInPixels"></param>
        /// <returns></returns>
        public static bool setSingleCellBorders(FpSpread fps, int row, int col, int lineWidthInPixels)
        {
            ComplexBorderSide leftBorder = new ComplexBorderSide(Color.Black, lineWidthInPixels);
            ComplexBorderSide rightBorder = new ComplexBorderSide(Color.Black, lineWidthInPixels);
            ComplexBorderSide topBorder = new ComplexBorderSide(Color.Black, lineWidthInPixels);
            ComplexBorderSide bottomBorder = new ComplexBorderSide(Color.Black, lineWidthInPixels);
            fps.ActiveSheet.Cells[row, col].Border = new ComplexBorder(leftBorder, topBorder, rightBorder, bottomBorder);
            return true;
        }
        #endregion

        #region 设置指定区域简单表格线
        /// <summary>
        /// 设置指定区域简单表格线
        /// </summary>
        /// <param name="fps"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="?"></param>
        /// <param name="?"></param>
        /// <param name="col2"></param>
        /// <param name="lineWidthInPixels"></param>
        /// <returns></returns>
        public static bool SetSingleCellBordersForRange(FpSpread fps, int row, int col, int row2, int col2, int lineWidthInPixels)
        {
            ComplexBorderSide leftBorder = new ComplexBorderSide(Color.Black, lineWidthInPixels);
            ComplexBorderSide rightBorder = new ComplexBorderSide(Color.Black, lineWidthInPixels);
            ComplexBorderSide topBorder = new ComplexBorderSide(Color.Black, lineWidthInPixels);
            ComplexBorderSide bottomBorder = new ComplexBorderSide(Color.Black, lineWidthInPixels);
            fps.ActiveSheet.Cells[row, col, row2, col2].Border = new ComplexBorder(leftBorder, topBorder, rightBorder, bottomBorder);
            return true;
        }
        #endregion

        #region 设置指定区域简单左边线
        /// <summary>
        /// 设置指定区域简单左边线
        /// </summary>
        /// <param name="fps"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="row2"></param>
        /// <param name="col2"></param>
        /// <param name="lineWidthInPixels"></param>
        /// <returns></returns>
        public static bool setLeftBorderOfCellRange(FpSpread fps, int row, int col, int row2, int col2, int lineWidthInPixels)
        {
            ComplexBorderSide leftBorder = new ComplexBorderSide(Color.Black, lineWidthInPixels);
            fps.ActiveSheet.Cells[row, col, row2, col2].Border = new ComplexBorder(leftBorder, null, null, null);
            return true;
        }
        #endregion

        #region 设置指定区域简单上边线
        /// <summary>
        /// 设置指定区域简单上边线
        /// </summary>
        /// <param name="fps"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="row2"></param>
        /// <param name="col2"></param>
        /// <param name="lineWidthInPixels"></param>
        /// <returns></returns>
        public static bool setTopBorderOfCellRange(FpSpread fps, int row, int col, int row2, int col2, int lineWidthInPixels)
        {
            ComplexBorderSide TopBorder = new ComplexBorderSide(Color.Black, lineWidthInPixels);
            fps.ActiveSheet.Cells[row, col, row2, col2].Border = new ComplexBorder(null, TopBorder, null, null);
            return true;
        }
        #endregion

        #region 设置指定区域简单右边线
        /// <summary>
        /// 设置指定区域简单右边线
        /// </summary>
        /// <param name="fps"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="row2"></param>
        /// <param name="col2"></param>
        /// <param name="lineWidthInPixels"></param>
        /// <returns></returns>
        public static bool setRightBorderOfCellRange(FpSpread fps, int row, int col, int row2, int col2, int lineWidthInPixels)
        {
            ComplexBorderSide rightBorder = new ComplexBorderSide(Color.Black, lineWidthInPixels);
            fps.ActiveSheet.Cells[row, col, row2, col2].Border = new ComplexBorder(null, null, rightBorder, null);
            return true;
        }
        #endregion

        #region 设置指定区域简单下边线
        /// <summary>
        /// 设置指定区域简单下边线
        /// </summary>
        /// <param name="fps"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="row2"></param>
        /// <param name="col2"></param>
        /// <param name="lineWidthInPixels"></param>
        /// <returns></returns>
        public static bool setBottomBorderOfCellRange(FpSpread fps, int row, int col, int row2, int col2, int lineWidthInPixels)
        {
            ComplexBorderSide bottomBorder = new ComplexBorderSide(Color.Black, lineWidthInPixels);
            fps.ActiveSheet.Cells[row, col, row2, col2].Border = new ComplexBorder(null, null, null, bottomBorder);
            return true;
        }
        #endregion

        #region 设置指定单元格标签

        /// <summary>
        /// 设置指定单元格标签
        /// </summary>
        /// <param name="fps"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="tag"></param>
        /// <returns></returns>
        public static bool setCellTag(FpSpread fps, int row, int col, string tag)
        {
            fps.ActiveSheet.Models.Data.SetTag(row, col, tag);
            return true;
        }

        #endregion

        #region 得到指定单元格标签

        /// <summary>
        /// 得到指定单元格标签
        /// </summary>
        /// <param name="fps"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="tag"></param>
        /// <returns></returns>
        public static bool getCellTag(FpSpread fps, int row, int col)
        {
            fps.ActiveSheet.Models.Data.GetTag(row,col);
            return true;
        }

        #endregion


        /// <summary>
        /// 通过单元格名称返回当前列号
        /// </summary>
        /// <param name="CellName">单元格名称</param>
        /// <returns></returns>
        public static int getColumnNum(string CellName)
        {
            int retVal = 0;
            string rowNum = "";
            Regex r = new Regex(@"[a-zA-Z]+");
            Match m = r.Match(CellName);
            rowNum = m.Value.ToUpper();

            char[] ch = rowNum.ToCharArray();
            for (int i = 0; i < rowNum.Length; i++)
            {
                retVal += ((ch[i] - 'A') + 1) * (int)Math.Pow(26, rowNum.Length - 1 - i);
            }

            retVal = retVal - 1;
            return retVal;

        }

        /// <summary>
        /// 通过单元格名称返回当前行号
        /// </summary>
        /// <param name="CellName">单元格名称</param>
        /// <returns></returns>
        public static int getRowNum(string CellName)
        {
            int retVal = 0;
            Regex r = new Regex(@"[0-9]+");
            Match m = r.Match(CellName);
            retVal = int.Parse(m.Value) - 1;
            return retVal;
        }


        /// <summary>
        /// 没有使用
        /// </summary>
        /// <param name="CellName"></param>
        /// <returns></returns>
        public static int[] GetCellID(string CellName)
        {
            int[] retVal = new int[2];
            string rowNum = "";
            Regex rRow = new Regex(@"[a-zA-Z]+");
            Match mRow = rRow.Match(CellName);
            rowNum = mRow.Value.ToUpper();

            char[] ch = rowNum.ToCharArray();
            for (int i = 0; i < rowNum.Length; i++)
            {
                retVal[0] += ((ch[i] - 'A') + 1) * (int)Math.Pow(26, rowNum.Length - 1 - i);
            }
            retVal[0] = retVal[0] - 1;

            Regex rCol = new Regex(@"[0-9]+");
            Match mCol = rCol.Match(CellName);
            retVal[1] = int.Parse(mCol.Value.ToString()) - 1;
            return retVal;
        }


        //public static bool addSheets(FpSpread fps, int numOfSheets, int startingNumberOfColumns, int startingNumberOfRows, bool protectionLikeExcelTF, Color sheetBackColor, HeaderAutoText rowHeaderAutoText, HeaderAutoText ColumnHeaderAutoText) 
        //{
        //    //'Adds a Sheet for Each Question and Sets the number of Rows and Column
        //    int x, y, z;
        //    fps.Sheets.Count = 0;
        //    //'Create the Sheets
        //    for int x=0,
        //}

        //Public Function AddSheets(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal NumberOfSheets As Integer, ByVal StartingNumberOfColumns As Integer, ByVal StartingNumberOfRows As Integer, ByVal ProtectionLikeExcelTF As Boolean, ByVal SheetBackColor As System.Drawing.Color, ByVal RowHeaderAutoText As FarPoint.Win.Spread.HeaderAutoText, ByVal ColumnHeaderAutoText As FarPoint.Win.Spread.HeaderAutoText) As Boolean

        //Dim x As Integer
        //Dim y As Integer
        //Dim z As Integer
        //SSControlToUse.Sheets.Count = 0
        //'Create the Sheets
        //For x = 0 To NumberOfSheets
        //Dim s As New FarPoint.Win.Spread.SheetView
        //s.ColumnCount = StartingNumberOfColumns
        //s.RowCount = StartingNumberOfRows
        //SSControlToUse.Sheets.Add(s)
        //Dim info As New FarPoint.Win.Spread.StyleInfo
        //'Set the BackColor
        //info.BackColor = SheetBackColor
        //SSControlToUse.Sheets(SSControlToUse.Sheets.Count - 1).DefaultStyle = info
        //'Set Protection Scheme to be like Excels for each sheet
        //For y = 0 To (StartingNumberOfRows - 1)
        //For z = 0 To (StartingNumberOfColumns - 1)
        //s.Cells(y, z).Locked = ProtectionLikeExcelTF
        //Next z
        //Next y
        //SSControlToUse.Sheets(x).RowHeaderAutoText = RowHeaderAutoText
        //SSControlToUse.Sheets(x).ColumnHeaderAutoText = ColumnHeaderAutoText
        //Next x
        //AddSheets = True
        //End Function 'AddSheets


        //Public Function AddSingleSheet(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal StartingNumberOfColumns As Integer, ByVal StartingNumberOfRows As Integer, ByVal ProtectionLikeExcelTF As Boolean, ByVal SheetBackColor As System.Drawing.Color, ByVal RowHeaderAutoText As FarPoint.Win.Spread.HeaderAutoText, ByVal ColumnHeaderAutoText As FarPoint.Win.Spread.HeaderAutoText) As Boolean
        //'Adds a Sheet for Each Question and Sets the number of Rows and Column
        //Dim x As Integer
        //Dim y As Integer
        //'Create the Sheets
        //Dim s As New FarPoint.Win.Spread.SheetView
        //s.ColumnCount = StartingNumberOfColumns
        //s.RowCount = StartingNumberOfRows
        //SSControlToUse.Sheets.Add(s)
        //Dim info As New FarPoint.Win.Spread.StyleInfo
        //'Set the BackColor
        //info.BackColor = SheetBackColor
        //SSControlToUse.Sheets(SSControlToUse.Sheets.Count - 1).DefaultStyle = info
        //'Set Protection Scheme to be like Excels for each sheet
        //For x = 0 To (StartingNumberOfRows - 1)
        //For y = 0 To (StartingNumberOfColumns - 1)
        //s.Cells(x, y).Locked = ProtectionLikeExcelTF
        //Next y
        //Next x
        //SSControlToUse.Sheets(SSControlToUse.Sheets.Count - 1).RowHeaderAutoText = RowHeaderAutoText
        //SSControlToUse.Sheets(SSControlToUse.Sheets.Count - 1).ColumnHeaderAutoText = ColumnHeaderAutoText
        //SSControlToUse.Sheets(SSControlToUse.Sheets.Count - 1).GrayAreaBackColor = Color.SlateGray
        //' Set operation mode and let users select multiple blocks of cells 
        //SSControlToUse.Sheets(SSControlToUse.Sheets.Count - 1).OperationMode = FarPoint.Win.Spread.OperationMode.Normal
        //SSControlToUse.Sheets(SSControlToUse.Sheets.Count - 1).SelectionPolicy = FarPoint.Win.Spread.Model.SelectionPolicy.MultiRange
        //AddSingleSheet = True
        //End Function 'AddSingleSheet


        //Public Function SSControlGlobals(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal EditModePermanentEntireWorkBookTF As Boolean, ByVal AllowCellOverFlowEntireWorkBookTF As Boolean, ByVal ControlsTabStripPolicy As FarPoint.Win.Spread.TabStripPolicy, ByVal TabStripPercentToShow As Single) As Boolean
        //' Set the sheet tabs policy
        //SSControlToUse.TabStripPolicy = ControlsTabStripPolicy
        //' Set the Tab Strip width to: .??
        //SSControlToUse.TabStripRatio = TabStripPercentToShow
        //'Eliminate the focus rectangle for the ENTIRE Control
        //SSControlToUse.EditModePermanent = EditModePermanentEntireWorkBookTF
        //'Allow Cell Text Overflow for the ENTIRE Control
        //SSControlToUse.AllowCellOverflow = AllowCellOverFlowEntireWorkBookTF

        //SSControlToUse.SelectionBlockOptions = FarPoint.Win.Spread.SelectionBlockOptions.Cells


        //End Function


        //Public Function TurnProtectionOnOffForAllSheetsInControl(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal TurnProtectionOn As Boolean) As Boolean
        //Dim x As Integer
        //Dim NumberOfSheets As Int16 = SSControlToUse.Sheets.Count

        //For x = 0 To NumberOfSheets - 1
        //SSControlToUse.Sheets(x).Protect = TurnProtectionOn
        //Next x
        //End Function


        //Public Function SetFont(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal Row As Integer, ByVal Col As Integer, ByVal Row2 As Integer, ByVal Col2 As Integer, ByVal FontFamily As String, ByVal FontSize As Integer, ByRef FontStyle As FontStyle) As Boolean
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).Font = New Font(FontFamily, FontSize, FontStyle)
        //SetFont = True
        //End Function 'SetFontBold


        //Public Function SetCellSpan(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal StartRow As Integer, ByVal StartCol As Integer, ByVal RowsToSpanCount As Integer, ByVal ColsToSpanCount As Integer) As Boolean
        //SSControlToUse.ActiveSheet.AddSpanCell(StartRow, StartCol, RowsToSpanCount, ColsToSpanCount)
        //SetCellSpan = True
        //End Function 'SetCellSpan


        //Public Function SetCellTypeTextForRange(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal Row As Integer, ByVal Col As Integer, ByVal Row2 As Integer, ByVal Col2 As Integer, ByVal MultilineTF As Boolean, ByVal WordWrapTF As Boolean, ByVal ReadOnlyTF As Boolean, ByVal TypeOfScrollBars As System.Windows.Forms.ScrollBars, ByVal MaximumNumberOfCharacters As Int16, ByVal IsLockWhenProtected As Boolean) As Boolean
        //Dim ct As New FarPoint.Win.Spread.CellType.TextCellType
        //ct.Multiline = MultilineTF
        //ct.WordWrap = WordWrapTF
        //ct.ReadOnly = ReadOnlyTF
        //ct.ScrollBars = TypeOfScrollBars
        //ct.MaxLength = MaximumNumberOfCharacters
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).CellType = ct
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).Locked = IsLockWhenProtected
        //SetCellTypeTextForRange = True
        //End Function 'SetCellTypeTextForRange

        //Public Function SetCellTypeGeneralForRange(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal Row As Integer, ByVal Col As Integer, ByVal Row2 As Integer, ByVal Col2 As Integer, ByVal WordWrapTF As Boolean, ByVal IsLockWhenProtected As Boolean) As Boolean
        //Dim ct As New FarPoint.Win.Spread.CellType.GeneralCellType
        //ct.WordWrap = WordWrapTF
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).CellType = ct
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).Locked = IsLockWhenProtected
        //SetCellTypeGeneralForRange = True
        //End Function 'SetCellTypeGeneralForRange

        //Public Function SetCellTypeButtonForRange(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal Row As Integer, ByVal Col As Integer, ByVal Row2 As Integer, ByVal Col2 As Integer, ByVal ButtonColor As Color, ByVal ButtonText As String, ByVal ButtonTextColor As Color, ByVal WordWrapTF As Boolean, ByVal IsLockWhenProtected As Boolean) As Boolean
        //Dim ct As New FarPoint.Win.Spread.CellType.ButtonCellType
        //ct.ButtonColor = ButtonColor
        //ct.Text = ButtonText
        //ct.TextColor = ButtonTextColor
        //ct.WordWrap = WordWrapTF
        //ct.TwoState = False
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).CellType = ct
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).Locked = IsLockWhenProtected
        //SetCellTypeButtonForRange = True
        //End Function 'SetCellTypeButtonForRange


        //Public Function SetCellTypeRadioButtonForRange(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal Row As Integer, ByVal Col As Integer, ByVal Row2 As Integer, ByVal Col2 As Integer, ByVal RadioButtonItemsTextVBTabbed As String, ByVal RadioBtnOrientation As FarPoint.Win.RadioOrientation, ByVal FontFamily As String, ByVal FontSize As Integer, ByRef FontStyle As FontStyle, ByVal IsLockWhenProtected As Boolean) As Boolean
        //Dim ct As New FarPoint.Win.Spread.CellType.MultiOptionCellType
        //'MUST Send In Item List as vbTab separated text
        //Dim ItemList() As String = Split(RadioButtonItemsTextVBTabbed, vbTab)
        //ct.Items = ItemList
        //ct.Orientation = RadioBtnOrientation
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).CellType = ct
        //'SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).BackColor = RadioBtnBackColor
        //'SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).BackColor = RadioBtnForeColor
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).Font = New Font(FontFamily, FontSize, FontStyle)
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).Locked = IsLockWhenProtected
        //SetCellTypeRadioButtonForRange = True
        //End Function 'SetCellTypeRadioButtonForRange

        //Public Function SetCellTypeCheckBoxForRange(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal Row As Integer, ByVal Col As Integer, ByVal Row2 As Integer, ByVal Col2 As Integer, ByVal ChkBoxTextAlgnment As FarPoint.Win.ButtonTextAlign, ByVal ChkBoxTextIfTrue As String, ByVal ChkBoxTextIfFalse As String, ByVal ChkBoxBackColor As Color, ByVal ChkBoxForeColor As Color, ByVal FontFamily As String, ByVal FontSize As Integer, ByRef FontStyle As FontStyle, ByVal IsLockWhenProtected As Boolean) As Boolean
        //Dim ct As New FarPoint.Win.Spread.CellType.CheckBoxCellType
        //ct.TextAlign = ChkBoxTextAlgnment
        //ct.TextTrue = ChkBoxTextIfTrue
        //ct.TextFalse = ChkBoxTextIfFalse
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).CellType = ct
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).BackColor = ChkBoxBackColor
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).ForeColor = ChkBoxForeColor
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).Font = New Font(FontFamily, FontSize, FontStyle)
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).Locked = IsLockWhenProtected
        //SetCellTypeCheckBoxForRange = True
        //End Function 'SetCellTypeCheckBoxForRange


        //Public Function SetCellTypeComboBoxForRange(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal Row As Integer, ByVal Col As Integer, ByVal Row2 As Integer, ByVal Col2 As Integer, ByVal ComboTextEditable As Boolean, ByVal ComboBoxItemsTextVBTabbed As String, ByVal ComboListAlignment As FarPoint.Win.ListAlignment, ByVal PixelsToOffsetListFromAttachedCell As Integer, ByVal ListWidthInPixels As Integer, ByVal NumbeofItemsToDisplayInDropdown As Integer, ByVal MaxLengthOfCharactersToDisplayInCell As Integer, ByVal ComboBoxBackColor As Color, ByVal ComboBoxForeColor As Color, ByVal FontFamily As String, ByVal FontSize As Integer, ByRef FontStyle As FontStyle, ByVal IsLockWhenProtected As Boolean) As Boolean
        //'MUST Send In Item List as vbTab separated text
        //Dim ct As New FarPoint.Win.Spread.CellType.ComboBoxCellType
        //'MUST Send In Item List as vbTab separated text
        //Dim ItemList() As String = Split(ComboBoxItemsTextVBTabbed, vbTab)
        //ct.Editable = ComboTextEditable
        //ct.Items = ItemList
        //ct.ListAlignment = ComboListAlignment
        //ct.ListOffset = PixelsToOffsetListFromAttachedCell
        //ct.ListWidth = ListWidthInPixels
        //ct.MaxDrop = NumbeofItemsToDisplayInDropdown
        //ct.MaxLength = MaxLengthOfCharactersToDisplayInCell
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).CellType = ct
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).BackColor = ComboBoxBackColor
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).ForeColor = ComboBoxForeColor
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).Font = New Font(FontFamily, FontSize, FontStyle)
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).Locked = IsLockWhenProtected
        //SetCellTypeComboBoxForRange = True
        //End Function 'SetCellTypeComboBoxForRange


        //Public Function SetCellTypeComboBoxForRangeFor1DArray(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal Row As Integer, ByVal Col As Integer, ByVal Row2 As Integer, ByVal Col2 As Integer, ByVal ComboTextEditable As Boolean, ByVal ComboBoxItemsText1DArray As String(), ByVal ComboListAlignment As FarPoint.Win.ListAlignment, ByVal PixelsToOffsetListFromAttachedCell As Integer, ByVal ListWidthInPixels As Integer, ByVal NumbeofItemsToDisplayInDropdown As Integer, ByVal MaxLengthOfCharactersToDisplayInCell As Integer, ByVal ComboBoxBackColor As Color, ByVal ComboBoxForeColor As Color, ByVal FontFamily As String, ByVal FontSize As Integer, ByRef FontStyle As FontStyle, ByVal IsLockWhenProtected As Boolean) As Boolean
        //Dim ct As New FarPoint.Win.Spread.CellType.ComboBoxCellType
        //ct.Editable = ComboTextEditable
        //ct.Items = ComboBoxItemsText1DArray
        //ct.ListAlignment = ComboListAlignment
        //ct.ListOffset = PixelsToOffsetListFromAttachedCell
        //ct.ListWidth = ListWidthInPixels
        //ct.MaxDrop = NumbeofItemsToDisplayInDropdown
        //ct.MaxLength = MaxLengthOfCharactersToDisplayInCell
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).CellType = ct
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).BackColor = ComboBoxBackColor
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).ForeColor = ComboBoxForeColor
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).Font = New Font(FontFamily, FontSize, FontStyle)
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).Locked = IsLockWhenProtected
        //SetCellTypeComboBoxForRangeFor1DArray = True
        //End Function 'SetCellTypeComboBoxForRangeFor1DArray


        //Public Function SetCellTypeMaskForRange(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal Row As Integer, ByVal Col As Integer, ByVal Row2 As Integer, ByVal Col2 As Integer, ByVal Mask As String, ByVal IsLockWhenProtected As Boolean) As Boolean
        //Dim maskcell As New FarPoint.Win.Spread.CellType.MaskCellType
        //maskcell.Mask = Mask
        //'maskcell.StringTrim = StringTrimming.Character
        //'maskcell.MaskChar = ""
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).CellType = maskcell
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).Locked = IsLockWhenProtected
        //SetCellTypeMaskForRange = True
        //End Function 'SetCellTypeMaskForRange


        //Public Function SetCellTypeNumberForRange(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal Row As Integer, ByVal Col As Integer, ByVal Row2 As Integer, ByVal Col2 As Integer, ByVal DecimalSeparator As String, ByVal DecimalPlaces As Integer, ByVal LeadingZero As FarPoint.Win.Spread.CellType.LeadingZero, ByVal MaximumValue As Double, ByVal MinimumValue As Double, ByVal IsLockWhenProtected As Boolean) As Boolean
        //Dim nmbrcell As New FarPoint.Win.Spread.CellType.NumberCellType
        //nmbrcell.DecimalSeparator = DecimalSeparator
        //nmbrcell.DecimalPlaces = DecimalPlaces
        //nmbrcell.LeadingZero = LeadingZero ' FarPoint.Win.Spread.CellType.LeadingZero.UseRegional
        //nmbrcell.MaximumValue = MaximumValue
        //nmbrcell.MinimumValue = MinimumValue
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).CellType = nmbrcell
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).Locked = IsLockWhenProtected
        //SetCellTypeNumberForRange = True
        //End Function 'SetCellTypeNumberForRange


        //Public Function SetRowHeaderText(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal Row As Integer, ByVal HorizontalAlignment As FarPoint.Win.spread.CellHorizontalAlignment, ByVal VerticalAlignment As FarPoint.Win.spread.CellVerticalAlignment, ByVal FontFamily As String, ByVal FontSize As Integer, ByRef FontStyle As FontStyle, ByVal LabelText As String) As Boolean
        //SSControlToUse.ActiveSheet.RowHeader.Rows(Row).HorizontalAlignment = HorizontalAlignment
        //SSControlToUse.ActiveSheet.RowHeader.Rows(Row).VerticalAlignment = VerticalAlignment
        //SSControlToUse.ActiveSheet.RowHeader.Rows(Row).Font = New Font(FontFamily, FontSize, FontStyle)
        //SSControlToUse.ActiveSheet.RowHeader.Rows(Row).Label = LabelText
        //SetRowHeaderText = True
        //End Function 'SetRowHeaderText


        //Public Function SetRowHeaderColumnCount(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal ColumnCount As Integer) As Boolean
        //Dim r As FarPoint.Win.Spread.RowHeader
        //r = SSControlToUse.ActiveSheet.RowHeader
        //r.ColumnCount = ColumnCount
        //SetRowHeaderColumnCount = True
        //End Function 'SetRowHeaderColumnCount


        //Public Function SetRowHeaderBackColor(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal RowStart As Integer, ByVal ColumnStartWithinHeader As Integer, ByVal RowEnd As Integer, ByVal ColumnEndWithinHeader As Integer, ByVal BackColor As System.Drawing.Color) As Boolean
        //Dim rh As FarPoint.Win.Spread.RowHeader
        //rh = SSControlToUse.ActiveSheet.RowHeader
        //rh.Cells(RowStart, ColumnStartWithinHeader, RowEnd, ColumnEndWithinHeader).BackColor = BackColor
        //SetRowHeaderBackColor = True
        //End Function 'SetRowHeaderBackColor


        //Public Function SetSpecialRowHeaderText(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal RowStart As Integer, ByVal ColumnStartWithinHeader As Integer, ByVal RowEnd As Integer, ByVal ColumnEndWithinHeader As Integer, ByVal HorizontalAlignment As FarPoint.Win.Spread.CellHorizontalAlignment, ByVal VerticalAlignment As FarPoint.Win.Spread.CellVerticalAlignment, ByVal FontFamily As String, ByVal FontSize As Integer, ByRef FontStyle As FontStyle, ByVal BackColor As System.Drawing.Color, ByVal foreColor As System.Drawing.Color, ByVal TheText As String) As Boolean
        //Dim rh As FarPoint.Win.Spread.RowHeader
        //rh = SSControlToUse.ActiveSheet.RowHeader
        //rh.Cells(RowStart, ColumnStartWithinHeader, RowEnd, ColumnEndWithinHeader).HorizontalAlignment = HorizontalAlignment
        //rh.Cells(RowStart, ColumnStartWithinHeader, RowEnd, ColumnEndWithinHeader).VerticalAlignment = VerticalAlignment
        //rh.Cells(RowStart, ColumnStartWithinHeader, RowEnd, ColumnEndWithinHeader).Font = New Font(FontFamily, FontSize, FontStyle)
        //rh.Cells(RowStart, ColumnStartWithinHeader, RowEnd, ColumnEndWithinHeader).BackColor = BackColor
        //rh.Cells(RowStart, ColumnStartWithinHeader, RowEnd, ColumnEndWithinHeader).ForeColor = foreColor
        //rh.Cells(RowStart, ColumnStartWithinHeader, RowEnd, ColumnEndWithinHeader).Text = TheText
        //SetSpecialRowHeaderText = True
        //End Function 'SetSpecialRowHeaderText


        //Public Function SetSpecialColumnHeaderText(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal RowStartWithinHeader As Integer, ByVal ColumnStart As Integer, ByVal RowEndWithinHeader As Integer, ByVal ColumnEnd As Integer, ByVal HorizontalAlignment As FarPoint.Win.Spread.CellHorizontalAlignment, ByVal VerticalAlignment As FarPoint.Win.Spread.CellVerticalAlignment, ByVal FontFamily As String, ByVal FontSize As Integer, ByRef FontStyle As FontStyle, ByVal BackColor As System.Drawing.Color, ByVal foreColor As System.Drawing.Color, ByVal TheText As String) As Boolean
        //Dim ch As FarPoint.Win.Spread.ColumnHeader
        //ch = SSControlToUse.ActiveSheet.ColumnHeader
        //ch.Cells(RowStartWithinHeader, ColumnStart, RowEndWithinHeader, ColumnEnd).HorizontalAlignment = HorizontalAlignment
        //ch.Cells(RowStartWithinHeader, ColumnStart, RowEndWithinHeader, ColumnEnd).VerticalAlignment = VerticalAlignment
        //ch.Cells(RowStartWithinHeader, ColumnStart, RowEndWithinHeader, ColumnEnd).Font = New Font(FontFamily, FontSize, FontStyle)
        //ch.Cells(RowStartWithinHeader, ColumnStart, RowEndWithinHeader, ColumnEnd).BackColor = BackColor
        //ch.Cells(RowStartWithinHeader, ColumnStart, RowEndWithinHeader, ColumnEnd).ForeColor = foreColor
        //ch.Cells(RowStartWithinHeader, ColumnStart, RowEndWithinHeader, ColumnEnd).Text = TheText
        //SetSpecialColumnHeaderText = True
        //End Function 'SetSpecialColumnHeaderText


        //Public Function SetRowHeaderForeColor(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal RowStart As Integer, ByVal ColumnStartWithinHeader As Integer, ByVal RowEnd As Integer, ByVal ColumnEndWithinHeader As Integer, ByVal ForeColor As System.Drawing.Color) As Boolean
        //Dim rh As FarPoint.Win.Spread.RowHeader
        //rh = SSControlToUse.ActiveSheet.RowHeader
        //rh.Cells(RowStart, ColumnStartWithinHeader, RowEnd, ColumnEndWithinHeader).ForeColor = ForeColor
        //SetRowHeaderForeColor = True
        //End Function 'SetRowHeaderBackColor


        //Public Function SetColumnHeaderText(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal Col As Integer, ByVal HorizontalAlignment As FarPoint.Win.spread.CellHorizontalAlignment, ByVal VerticalAlignment As FarPoint.Win.spread.CellVerticalAlignment, ByVal FontFamily As String, ByVal FontSize As Integer, ByRef FontStyle As FontStyle, ByVal LabelText As String) As Boolean
        //SSControlToUse.ActiveSheet.ColumnHeader.Columns(Col).HorizontalAlignment = HorizontalAlignment
        //SSControlToUse.ActiveSheet.ColumnHeader.Columns(Col).VerticalAlignment = VerticalAlignment
        //SSControlToUse.ActiveSheet.ColumnHeader.Columns(Col).Font = New Font(FontFamily, FontSize, FontStyle)
        //SSControlToUse.ActiveSheet.ColumnHeader.Columns(Col).Label = LabelText
        //SetColumnHeaderText = True
        //End Function 'SetColumnHeaderText


        //Public Function SetColumnHeaderRowCount(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal RowCount As Integer) As Boolean
        //Dim r As FarPoint.Win.Spread.ColumnHeader
        //r = SSControlToUse.ActiveSheet.ColumnHeader
        //r.RowCount = RowCount
        //SetColumnHeaderRowCount = True
        //End Function 'SetRowHeaderColumnCount


        //Public Function SetColumnHeaderSpan(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal Row As Integer, ByVal Column As Integer, ByVal RowCount As Integer, ByVal ColumnCount As Integer) As Boolean
        //SSControlToUse.ActiveSheet.AddColumnHeaderSpanCell(Row, Column, RowCount, ColumnCount)
        //End Function


        //Public Function SetColumnHeaderBackColor(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal RowStartWithinHeader As Integer, ByVal ColumnStart As Integer, ByVal RowEndWithinHeader As Integer, ByVal ColumnEnd As Integer, ByVal BackColor As System.Drawing.Color) As Boolean
        //Dim rh As FarPoint.Win.Spread.ColumnHeader
        //rh = SSControlToUse.ActiveSheet.ColumnHeader
        //rh.Cells(RowStartWithinHeader, ColumnStart, RowEndWithinHeader, ColumnEnd).BackColor = BackColor
        //SetColumnHeaderBackColor = True
        //End Function 'SetColumnHeaderBackColor


        //Public Function SetColumnHeaderForeColor(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal RowStartWithinHeader As Integer, ByVal ColumnStart As Integer, ByVal RowEndWithinHeader As Integer, ByVal ColumnEnd As Integer, ByVal ForeColor As System.Drawing.Color) As Boolean
        //Dim rh As FarPoint.Win.Spread.ColumnHeader
        //rh = SSControlToUse.ActiveSheet.ColumnHeader
        //rh.Cells(RowStartWithinHeader, ColumnStart, RowEndWithinHeader, ColumnEnd).ForeColor = ForeColor
        //SetColumnHeaderForeColor = True
        //End Function 'SetColumnHeaderForeColor

        //Public Function ClearComboBoxForRange(ByRef SSControlToUse As FarPoint.Win.Spread.FpSpread, ByVal Row As Integer, ByVal Col As Integer, ByVal Row2 As Integer, ByVal Col2 As Integer) As Boolean
        //Dim ct As New FarPoint.Win.Spread.CellType.ComboBoxCellType
        //SSControlToUse.ActiveSheet.Cells(Row, Col, Row2, Col2).CellType = ct
        //ct.Clear()
        //ClearComboBoxForRange = True
        //End Function 'ClearComboBoxForRange

        public enum BorderStyle 
        {
            Left = 0,
            Top = 1,
            Right = 2,
            Bottom = 3,
            None = 4,
            Builder = 5,
            Full = 6,
            OutSide= 7,
            OutSideBold = 8
        }
    }
}


下载方式:https://pan.quark.cn/s/a4b39357ea24 布线问题(分支限界算法)是计算机科学和电子工程领域中一个广为人知的议题,它主要探讨如何在印刷电路板上定位两个节点间最短的连接路径。 在这一议题中,电路板被构建为一个包含 n×m 个方格的矩阵,每个方格能够被界定为可通行或不可通行,其核心任务是定位从初始点到最终点的最短路径。 分支限界算法是处理布线问题的一种常用策略。 该算法与回溯法有相似之处,但存在差异,分支限界法仅需获取满足约束条件的一个最优路径,并按照广度优先或最小成本优先的原则来探索解空间树。 树 T 被构建为子集树或排列树,在探索过程中,每个节点仅被赋予一次成为扩展节点的机会,且会一次性生成其全部子节点。 针对布线问题的解决,队列式分支限界法可以被采用。 从起始位置 a 出发,将其设定为首个扩展节点,并将与该扩展节点相邻且可通行的方格加入至活跃节点队列中,将这些方格标记为 1,即从起始方格 a 到这些方格的距离为 1。 随后,从活跃节点队列中提取队首节点作为下一个扩展节点,并将与当前扩展节点相邻且未标记的方格标记为 2,随后将这些方格存入活跃节点队列。 这一过程将持续进行,直至算法探测到目标方格 b 或活跃节点队列为空。 在实现上述算法时,必须定义一个类 Position 来表征电路板上方格的位置,其成员 row 和 col 分别指示方格所在的行和列。 在方格位置上,布线能够沿右、下、左、上四个方向展开。 这四个方向的移动分别被记为 0、1、2、3。 下述表格中,offset[i].row 和 offset[i].col(i=0,1,2,3)分别提供了沿这四个方向前进 1 步相对于当前方格的相对位移。 在 Java 编程语言中,可以使用二维数组...
源码来自:https://pan.quark.cn/s/a4b39357ea24 在VC++开发过程中,对话框(CDialog)作为典型的用户界面组件,承担着与用户进行信息交互的重要角色。 在VS2008SP1的开发环境中,常常需要满足为对话框配置个性化背景图片的需求,以此来优化用户的操作体验。 本案例将系统性地阐述在CDialog框架下如何达成这一功能。 首先,需要在资源设计工具中构建一个新的对话框资源。 具体操作是在Visual Studio平台中,进入资源视图(Resource View)界面,定位到对话框(Dialog)分支,通过右键选择“插入对话框”(Insert Dialog)选项。 完成对话框内控件的布局设计后,对对话框资源进行保存。 随后,将着手进行背景图片的载入工作。 通常有两种主要的技术路径:1. **运用位图控件(CStatic)**:在对话框界面中嵌入一个CStatic控件,并将其属性设置为BST_OWNERDRAW,从而具备自主控制绘制过程的权限。 在对话框的类定义中,需要重写OnPaint()函数,负责调用图片资源并借助CDC对象将其渲染到对话框表面。 此外,必须合理处理WM_CTLCOLORSTATIC消息,确保背景图片的展示不会受到其他界面元素的干扰。 ```cppvoid CMyDialog::OnPaint(){ CPaintDC dc(this); // 生成设备上下文对象 CBitmap bitmap; bitmap.LoadBitmap(IDC_BITMAP_BACKGROUND); // 获取背景图片资源 CDC memDC; memDC.CreateCompatibleDC(&dc); CBitmap* pOldBitmap = m...
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值