MESCIUS SPREAD for Windows Forms 15.0J
FillSpreadDataByDataSource() メソッド
使用例 

データソースのデータをSpreadデータに読み込みます。
構文
'宣言
 
Public Sub FillSpreadDataByDataSource() 
public void FillSpreadDataByDataSource()
使用例
次のサンプルコードは、FillSpreadDataByDataSourceメソッドを使用します。
DataSet ds = new DataSet();
DataTable dt = default(DataTable);
dt = new DataTable();
dt.Columns.Add(new DataColumn("Number1", typeof(string)));
dt.Columns.Add(new DataColumn("Number2", typeof(string)));
dt.Columns.Add(new DataColumn("Number3", typeof(string)));
dt.Columns.Add(new DataColumn("Text1", typeof(string)));
dt.Columns.Add(new DataColumn("Text2", typeof(string)));
dt.Columns.Add(new DataColumn("Text3", typeof(string)));
dt.Columns.Add(new DataColumn("Text4", typeof(decimal)));
dt.Rows.Add(new object[] { "101", "1", "0", "Num1", "Num2", "Num3", 21000 });
dt.Rows.Add(new object[] { "201", "2", "0", "a", "b", "c", 9400 });
dt.Rows.Add(new object[] { "203", "2", "0", "Jan", "Feb", "March", 4550 });
dt.Rows.Add(new object[] { "301", "3", "1", "First", "Second", "Third", 32000 });
dt.Rows.Add(new object[] { "302", "3", "1", "Test", "Test1", "Test2", 13280 });
dt.Rows.Add(new object[] { "204", "2", "0", "Mon", "Tues", "Wed", 1700 });
dt.Rows.Add(new object[] { "303", "3", "1", "Week1", "Week2", "Week3", 36080 });
dt.Rows.Add(new object[] { "402", "4", "1", "d", "e", "f", 31500 });
dt.Rows.Add(new object[] { "405", "4", "1", "July", "August", "September", 4958 });
dt.Rows.Add(new object[] { "102", "1", "0", "next", "aaa", "max", 1539 });
ds.Tables.Add(dt);

FarPoint.Win.Spread.Data.SpreadDataBindingAdapter Sdba = new FarPoint.Win.Spread.Data.SpreadDataBindingAdapter();
Sdba.DataSource = ds.Tables[0];
Sdba.Spread = fpSpread1;
Sdba.SheetName = fpSpread1.ActiveSheet.SheetName;
Sdba.AutoGenerateRow = true;
Sdba.DataAutoCellTypes = false;  
Sdba.MapperInfo = new FarPoint.Win.Spread.Data.MapperInfo(2, 0, 10, 7);   
Sdba.FillSpreadDataByDataSource();
Dim ds As New DataSet()
Dim dt As DataTable = Nothing
dt = New DataTable()
dt.Columns.Add(New DataColumn("Number1", GetType(String)))
dt.Columns.Add(New DataColumn("Number2", GetType(String)))
dt.Columns.Add(New DataColumn("Number3", GetType(String)))
dt.Columns.Add(New DataColumn("Text1", GetType(String)))
dt.Columns.Add(New DataColumn("Text2", GetType(String)))
dt.Columns.Add(New DataColumn("Text3", GetType(String)))
dt.Columns.Add(New DataColumn("Text4", GetType(Decimal)))
dt.Rows.Add(New Object() {"101", "1", "0", "Num1", "Num2", "Num3", 21000})
dt.Rows.Add(New Object() {"201", "2", "0", "a", "b", "c", 9400})
dt.Rows.Add(New Object() {"203", "2", "0", "Jan", "Feb", "March", 4550})
dt.Rows.Add(New Object() {"301", "3", "1", "First", "Second", "Third", 32000})
dt.Rows.Add(New Object() {"302", "3", "1", "Test", "Test1", "Test2", 13280})
dt.Rows.Add(New Object() {"204", "2", "0", "Mon", "Tues", "Wed", 1700})
dt.Rows.Add(New Object() {"303", "3", "1", "Week1", "Week2", "Week3", 36080})
dt.Rows.Add(New Object() {"402", "4", "1", "d", "e", "f", 31500})
dt.Rows.Add(New Object() {"405", "4", "1", "July", "August", "September", 4958})
dt.Rows.Add(New Object() {"102", "1", "0", "next", "aaa", "max", 1539})
ds.Tables.Add(dt)

Dim Sdba As New FarPoint.Win.Spread.Data.SpreadDataBindingAdapter()
Sdba.DataSource = ds.Tables(0)
Sdba.Spread = FpSpread1
Sdba.SheetName = FpSpread1.ActiveSheet.SheetName
Sdba.AutoGenerateRow = True
Sdba.DataAutoCellTypes = False
Sdba.MapperInfo = New FarPoint.Win.Spread.Data.MapperInfo(2, 0, 10, 7)
Sdba.FillSpreadDataByDataSource()
参照

SpreadDataBindingAdapter クラス
SpreadDataBindingAdapter メンバ

 

 


© MESCIUS inc. All rights reserved.