我使用了几种方法,以及这几种方法混合使用,均无法删除和重新绑定。请版主帮我看看代码,怎么操作可以重新绑定。
fpSpread1.AsWorkbook().ActiveSheet.Tables.DataSource = null;
fpSpread1.AsWorkbook().ActiveSheet.Tables.Delete(true);
fpSpread1.AsWorkbook().ActiveSheet.Tables.Delete();
fpSpread1.AsWorkbook().ActiveSheet.Tables.Unlist();
private void btnSetData2()
{
//fpSpread1.AsWorkbook().ActiveSheet.Worksheet.Delete();
for (var i = 0; i < fpSpread1.AsWorkbook().ActiveSheet.Tables.Count; i++)
{
//var tb = fpSpread1.AsWorkbook().ActiveSheet.Tables;
//tb.Delete();
//fpSpread1.AsWorkbook().ActiveSheet.Tables.Worksheet.Delete();
//fpSpread1.AsWorkbook().ActiveSheet.Tables.DataSource = null;
//fpSpread1.AsWorkbook().ActiveSheet.Tables.Delete(true);
fpSpread1.AsWorkbook().ActiveSheet.Tables.Delete();
//fpSpread1.AsWorkbook().ActiveSheet.Tables.Unlist();
}
fpSpread1.Sheets[0].Rows[2, fpSpread1.ActiveSheet.Rows.Count - 1].Visible = false;
fpSpread1.Sheets[0].Columns[10, fpSpread1.ActiveSheet.Columns.Count - 1].Visible = false;
int RowsCount = 1;
for (int i = 0; i < ds.Tables.Count; i++)
{
GrapeCity.Spreadsheet.IWorksheet TestActiveSheet = fpSpread1.AsWorkbook().ActiveSheet;
//TestActiveSheet.AutoFilterMode = false;
string nRange = "A" + (RowsCount) + ":G" + (RowsCount + ds.Tables.Rows.Count + 2);
GrapeCity.Spreadsheet.ITable table = TestActiveSheet.Range(nRange).CreateTable(true);
table.ShowAutoFilter = false;
table.AutoGenerateColumns = true;
table.DataSource = ds.Tables;
table.Name = i.ToString();
RowsCount += ds.Tables.Rows.Count + 1;
fpSpread1.ActiveSheet.Rows[0, RowsCount - i].Visible = true;
fpSpread1.ActiveSheet.Columns[0, ds.Tables.Columns.Count - 1].Visible = true;
}
FarPoint.Win.Spread.CellType.CheckBoxCellType dateType = new FarPoint.Win.Spread.CellType.CheckBoxCellType();
fpSpread1.Sheets[0].Columns[0].CellType = dateType;
fpSpread1.ActiveSheet.Columns[0, 10].Width = 100;
//fpSpread1.ActiveSheet.Columns[1, 5].Locked = true;
//fpSpread1.ActiveSheet.Protect = true;
}
|