Exemplo n.º 1
0
        // float
        public bool SetValue(int row, int col, float result)
        {
            if (row >= GetRowCount() || col >= GetColcount() || row < 0 || col < 0)
            {
                return(false);
            }

            VarList rowItem = rowSet[row];

            if (rowItem == null)
            {
                return(false);
            }

            if (col < rowItem.GetCount())
            {
                rowItem.SetFloat(col, result);
            }
            else
            {
                rowItem.AddFloat(result);
            }

            return(true);
        }
Exemplo n.º 2
0
        public bool SetValue(int row, int col, Var result)
        {
            try
            {
                if (row >= GetRowCount() || col >= GetColcount() ||
                    row < 0 || col < 0)
                {
                    return(false);
                }

                if (null == result)
                {
                    return(false);
                }

                VarList rowItem = rowSet[row];
                if (rowItem == null)
                {
                    return(false);
                }

                if (col > rowItem.GetCount())
                {
                    //Log.Trace("col error col=" + col.ToString());
                    return(false);
                }

                switch (result.Type)
                {
                case VarType.Int:
                {
                    if (col < rowItem.GetCount())
                    {
                        rowItem.SetInt(col, result.GetInt());
                    }
                    else
                    {
                        rowItem.AddInt(result.GetInt());
                    }
                }
                break;

                case VarType.Int64:
                {
                    if (col < rowItem.GetCount())
                    {
                        rowItem.SetInt64(col, result.GetInt64());
                    }
                    else
                    {
                        rowItem.AddInt64(result.GetInt64());
                    }
                }
                break;

                case VarType.Float:
                {
                    if (col < rowItem.GetCount())
                    {
                        rowItem.SetFloat(col, result.GetFloat());
                    }
                    else
                    {
                        rowItem.AddFloat(result.GetFloat());
                    }
                }
                break;

                case VarType.Double:
                {
                    if (col < rowItem.GetCount())
                    {
                        rowItem.SetDouble(col, result.GetDouble());
                    }
                    else
                    {
                        rowItem.AddDouble(result.GetDouble());
                    }
                }
                break;

                case VarType.String:
                {
                    if (col < rowItem.GetCount())
                    {
                        rowItem.SetString(col, result.GetString());
                    }
                    else
                    {
                        rowItem.AddString(result.GetString());
                    }
                }
                break;

                case VarType.WideStr:
                {
                    if (col < rowItem.GetCount())
                    {
                        rowItem.SetWideStr(col, result.GetWideStr());
                    }
                    else
                    {
                        rowItem.AddWideStr(result.GetWideStr());
                    }
                }
                break;

                case VarType.Object:
                {
                    if (col < rowItem.GetCount())
                    {
                        rowItem.SetObject(col, result.GetObject());
                    }
                    else
                    {
                        rowItem.AddObject(result.GetObject());
                    }
                }
                break;

                default:
                    //Log.Trace("typer error type=" + result.Type.ToString());
                    return(false);
                }//end switch

                //rowSet[row] = rowItem;
                //int nCount = rowItem.GetCount();
                return(true);
            }
            catch (Exception ex)
            {
                Log.TraceExcep(ref ex);
                return(false);
            }
        }