rdl スキーマから生成したオブジェクト モデルを使用して、プログラムで rdl を作成しようとしています。まず、ヘッダー フッターと本文、およびデータソースとデータセット セクションを含む既存の rdl テンプレートをファイル ストリームに読み込みます。
string docpath = "RDLTemplates/TemplateLetter.rdl";
Report myReport = null;
using (FileStream fs = new FileStream(docpath, FileMode.Open))
{
XmlSerializer serializer = new XmlSerializer(typeof(Report));
myReport = (Report)serializer.Deserialize(fs);
}
return myReport;
次に、これをメソッドに渡しInsertTablix()
、ストリームをナビゲートして本文セクションを見つけます
public Report InsertTablix(Report report, List<string> fieldnames)
{
int sectionindex = report.ItemsElementName.ToList().IndexOf(ItemsChoiceType118.ReportSections);
if (sectionindex != -1)
{
ReportSectionsType sections = (ReportSectionsType)report.Items[sectionindex];
if (sections.ReportSection.Length > 0)
{
int bodyIndex = sections.ReportSection[0].ItemsElementName.ToList().IndexOf(ItemsChoiceType117.Body);
if (bodyIndex != -1)
{
BodyType body = (BodyType)sections.ReportSection[0].Items[bodyIndex];
int tablixindex = body.Items.ToList().IndexOf(ItemsChoiceType80.Tablix);
if (tablixindex == -1)
{
//Here is where I would like to insert the tablix if it doesn't exist
}
}
}
}
return report;
}
私が立ち往生しているのは、オブジェクトモデルを使用してこの本体に Tablix を作成/挿入する方法です。XML を使用してレポートを作成できることを認識しており、このアプローチを試してみましたが、ObjectModel を使用して、レポート スキーマに準拠し、検証したいと考えていました。
このアプローチを使用して、要素 (tablix、テキストボックスなど) を本文に追加する方法について、だれでも洞察を提供できますか。
-乾杯