private void SetupMines(FlexCelReport MinesReport) { DataSet ds = new DataSet(); DataTable dtrows = ds.Tables.Add("datarow"); dtrows.Columns.Add("position", typeof(int)); DataTable dtcols = ds.Tables.Add("datacol"); dtcols.Columns.Add("position", typeof(int)); dtcols.Columns.Add("value", typeof(int)); ds.Relations.Add(dtrows.Columns["position"], dtcols.Columns["position"]); //let's create 10 mines. ArrayList mines = new ArrayList(); Random rnd = new Random(); while (mines.Count < 10) { int nextMine = rnd.Next(9 * 9 - 1); int minepos = mines.BinarySearch(nextMine); if (minepos >= 0) { continue; //the value already exists } mines.Insert(~minepos, nextMine); } //Fill the tables on master detail for (int r = 0; r < 9; r++) { dtrows.Rows.Add(new object[] { r }); for (int c = 0; c < 9; c++) { object[] values = new object[2]; values[0] = r; if (mines.BinarySearch(r * 9 + c) >= 0) { values[1] = 1; } else { values[1] = DBNull.Value; } dtcols.Rows.Add(values); } } //finally, add the tables to the report. MinesReport.ClearTables(); MinesReport.AddTable(ds, TDisposeMode.DisposeAfterRun); //leave to Flexcel to delete the dataset. }