1.使用設計器設計mrt報表模板,或者從其他文件復制修改
2.刪除business object 數據源
3.使用代碼添加數據源
ParcelChangeItem change = new ParcelChangeItem();
string filename = @"D:\worki\xxx信息.mrt";
Stimulsoft.Report.StiReport report = new StiReport();
report.Load(filename);
report.Dictionary.Clear();
report.RegBusinessObject("parcel", parcel);
report.Dictionary.SynchronizeBusinessObjects(1);
report.Dictionary.Synchronize();
report.Save(filename);
4.再綁定報表各字段,字段上右鍵,選設計。
5.使用
RegcardEx aa = new RegcardEx()
{
ExIndex = "22",
RegDate = "2015-9-9",
RegType = "初始登記",
RegContent = "aaaaa"
};
RegcardParcel parcel = new RegcardParcel()
{
ParcelCode = "aaaaaa",
IsAreaUnitSquaremeter = true,
OwnerName = "xt張三",
CardExItem = aa
};
StiReport report = new StiReport();
report.Load(@"F:\stimulsoft報表\報表模板\土地登記卡.mrt");
report.RegBusinessObject("land", "Regcard", parcel);
report.Compile();
report.Render(true);
report.Show();
注意,定義的對象,類名,與報表里的名稱關鍵字不可以重名,否則報對象已存在錯誤。
其他類型使用待補充
列表及底部邊線
List<RegcardEx> cers = new List<RegcardEx>() {
new RegcardEx(){ExIndex = "22",RegDate = "2015-9-9",RegType = "初始登記",RegContent = "aaaaa" },
new RegcardEx(){ExIndex = "22",RegDate = "2015-9-9",RegType = "初始登記",RegContent = "aaaaa" },
new RegcardEx(){ExIndex = "22",RegDate = "2015-9-9",RegType = "初始登記",RegContent = "aaaaa" },
new RegcardEx(){ExIndex = "22",RegDate = "2015-9-9",RegType = "初始登記",RegContent = "aaaaa" },
};
StiReport report = new StiReport();
report.Load(@"F:\stimulsoft報表\報表模板\土地登記卡續表.mrt");
report.RegBusinessObject("land", "cardex", cers);
report.Compile();
report.Render(true);
report.Show();
}