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;
        }
Beispiel #2
0
        public object Clone()
        {
            ToxyTable newtt = new ToxyTable();

            newtt.PageFooter      = this.PageFooter;
            newtt.PageHeader      = this.PageHeader;
            newtt.Name            = this.Name;
            newtt.LastColumnIndex = this.LastColumnIndex;
            newtt.LastRowIndex    = this.LastRowIndex;
            foreach (ToxyRow row in this.Rows)
            {
                newtt.Rows.Add(row.Clone() as ToxyRow);
            }
            foreach (ToxyRow header in this.HeaderRows)
            {
                newtt.HeaderRows.Add(header.Clone() as ToxyRow);
            }
            return(newtt);
        }
Beispiel #3
0
 private void ShowToGrid(ToxyTable table)
 {
     ssPanel.ReoGridControl.Reset();
     ssPanel.ReoGridControl.ColCount = table.LastColumnIndex + 1;
     ssPanel.ReoGridControl.RowCount = table.LastRowIndex + 2; 
     if(table.HasHeader)
         foreach (var cell in table.ColumnHeaders.Cells)
         {
             ssPanel.ReoGridControl.SetCellData(new ReoGridPos(0, cell.CellIndex), cell.Value);
         }
     foreach (var row in table.Rows)
     {
         foreach (var cell in row.Cells)
         {
             ssPanel.ReoGridControl.SetCellData(new ReoGridPos(row.RowIndex+1, cell.CellIndex), cell.Value);
         }
     }
     foreach (var cellrange in table.MergeCells)
     {
         ssPanel.ReoGridControl.MergeRange(new ReoGridRange(
             new ReoGridPos(cellrange.FirstRow, cellrange.FirstColumn),
             new ReoGridPos(cellrange.LastRow, cellrange.LastColumn)));
     }
 }
Beispiel #4
0
 private void ShowToGrid(ToxyTable table)
 {
     reoGridControl1.Reset();
     reoGridControl1.ColCount = table.LastColumnIndex + 1; 
     reoGridControl1.RowCount = table.LastRowIndex+1; 
     foreach (var row in table.Rows)
     {
         foreach (var cell in row.Cells)
         {
             reoGridControl1.SetCellData(new ReoGridPos(row.RowIndex, cell.CellIndex), cell.Value);
         }
     }
     foreach (var cellrange in table.MergeCells)
     {
         reoGridControl1.MergeRange(new ReoGridRange(
             new ReoGridPos(cellrange.FirstRow, cellrange.FirstColumn),
             new ReoGridPos(cellrange.LastRow, cellrange.LastColumn)));
     }
     //    dataGridView1.DataSource = table.ToDataTable().DefaultView;
 }
Beispiel #5
0
 public object Clone()
 {
     ToxyTable newtt = new ToxyTable();
     newtt.PageFooter = this.PageFooter;
     newtt.PageHeader = this.PageHeader;
     newtt.Name = this.Name;
     newtt.LastColumnIndex = this.LastColumnIndex;
     newtt.LastRowIndex = this.LastRowIndex;
     foreach(ToxyRow row in this.Rows)
     {
         newtt.Rows.Add(row.Clone() as ToxyRow);
     }
     foreach (ToxyRow header in this.HeaderRows)
     {
         newtt.HeaderRows.Add(header.Clone() as ToxyRow);
     }
     return newtt;
 }
        public ExcelTableTemplate Parse(string filepath)
        {
            var templateMetadata = new TemplateMetaData();
            if (filepath.StartsWith("/"))
                filepath = HostingEnvironment.MapPath(filepath);
            FilePath = filepath;
            ParserContext context = new ParserContext(filepath);
            ISpreadsheetParser parser = ParserFactory.CreateSpreadsheet(context);
            ToxySpreadsheet ss = parser.Parse();
            foreach (var table in ss.Tables)
            {
                _currTable = table;
                for (_currRowIndex = 0; _currRowIndex < table.Rows.Count; _currRowIndex++)
                {
                    var row = table.Rows[_currRowIndex];
                    for (_currColIndex = 0; _currColIndex < row.Cells.Count; _currColIndex++)
                    {
                        var cell = row.Cells[_currColIndex];

                        var tabletoken = ParseTable(cell);
                        if (tabletoken != null)
                        {
                            templateMetadata.Tables.Add(tabletoken);
                        }
                        else
                        {
                            var cellToken = ParseCell(cell);
                            if (cellToken != null)
                            {
                                templateMetadata.Cells.Add(cellToken);
                            }
                        }

                    }

                }

            }
            return null;
        }