我想知道如何从
XML创建一个水晶报表(
XML来自Web服务),我在一些教程中读到它需要找到文件并拖动报表中的字段,但是如何从一个XML中获取XML网络服务?
以下是我如何从Web服务获取XML的代码
var doc = XDocument.Parse(trx.GetCardTrx("xxxxx", "xxxx", "xxx", "", dateTimePicker1.Text, dateTimePicker2.Text, "", "", "", "", "", "", "", "", "", "", "", "FALSE", "", "", "", "", "", "", "", "", "", "", ""));
MessageBox.Show(doc.ToString());
所以这段代码返回这种值(来自MessageBox.Show(doc.ToString())
这是应该在报告中的选定值的代码
var summary = from r in doc.Descendants("TrxDetailCard")
select new
{
Account_Type = r.Element("Account_Type_CH").Value,
Captured = r.Element("Captured").Value,
Trans_Type_ID = r.Element("Trans_Type_ID").Value,
Acct_Num_CH = r.Element("Acct_Num_CH").Value,
Tip_Amt_MN = r.Element("Tip_Amt_MN").Value,
Total_Amt_MN = r.Element("Total_Amt_MN").Value,
Date_DT = r.Element("Date_DT").Value,
};
我想要发生的是使用Crystal Reports创建一个包含此值的报表,而不是所有值.仅选定值.我怎么可能这样做?任何想法都将是一个很大的帮助谢谢你:D
最佳答案 这尚未经过测试,但您可以尝试以下内容
using System.Xml;
using System.Xml.Linq;
var doc = XDocument.Parse(trx.GetCardTrx("xxxxx", "xxxx", "xxx", "", dateTimePicker1.Text, dateTimePicker2.Text, "", "", "", "", "", "", "", "", "", "", "", "FALSE", "", "", "", "", "", "", "", "", "", "", ""));
var data = new DataSet();
var context = new XmlParserContext(null, new XmlNamespaceManager(new NameTable()), null, XmlSpace.None);
var reader = doc
data.ReadXml(reader);
var report = new ReportDocument();
report.SetDataSource(data);
this.crystalReportViewer1.ReportSource.ReportSource = report;
理论上的理念应该有效,但你可以从这个链接中引用类似的东西
XML-based Crystal Report not updating child objects on refresh