public ToxySpreadsheet LoadData(DataContext context)
        {
            Database db = DatabaseFactory.CreateDatabase(context.ConnectionStringName);

            DbCommand cmd=db.GetSqlStringCommand(context.QueryString);
            ToxySpreadsheet ss = new ToxySpreadsheet();
            ss.Name = context.ConnectionStringName;
            int i=0;
            using(IDataReader reader=db.ExecuteReader(cmd))
            {
                ToxyTable table = new ToxyTable();
                table.Name = "Sheet1";
                ToxyRow row=new ToxyRow(i);
                if (i == 0)
                {
                    for (int j = 0; j < reader.FieldCount; j++)
                    {
                        row.Cells.Add(new ToxyCell(j, reader.GetName(i)));
                    }
                }
                else
                {
                    for (int j = 0; j < reader.FieldCount; j++)
                    {
                        string value=reader.GetString(j);
                        if(!string.IsNullOrEmpty(value))
                            row.Cells.Add(new ToxyCell(j, value));
                    }
                }
                table.Rows.Add(row);
                i++;
                ss.Tables.Add(table);
            }
            return ss;
        }
Esempio n. 2
0
 public object Clone()
 {
     ToxyRow clonedrow = new ToxyRow(this.RowIndex);
     foreach (ToxyCell cell in this.Cells)
     {
         clonedrow.Cells.Add(cell.Clone() as ToxyCell);
     }
     return clonedrow;
 }
Esempio n. 3
0
        public object Clone()
        {
            ToxyRow clonedrow = new ToxyRow(this.RowIndex);

            foreach (ToxyCell cell in this.Cells)
            {
                clonedrow.Cells.Add(cell.Clone() as ToxyCell);
            }
            return(clonedrow);
        }