Report 动态修改rdlc报告(c)

Report 动态修改rdlc报告(c),report,rdlc,Report,Rdlc,我在数据库中存储了一种字体,我必须用这种字体设置所有文件。 我将我的报告设置为如下绑定: FormBudgReelReport form = new FormBudgReelReport(); form.Viewer.LocalReport.ReportEmbeddedResource = _NomRessourceRpt; form.Viewer.LocalReport.DataSources.Add(source); form.ShowDialog(); 如果我可以将我的rdlc作为Xml

我在数据库中存储了一种字体,我必须用这种字体设置所有文件。 我将我的报告设置为如下绑定:

FormBudgReelReport form = new FormBudgReelReport();
form.Viewer.LocalReport.ReportEmbeddedResource = _NomRessourceRpt;
form.Viewer.LocalReport.DataSources.Add(source);
form.ShowDialog();
如果我可以将我的rdlc作为XmlDocument加载,我知道怎么做,但是有没有办法呢? 我不能使用像=参数这样的公式!警察,因为我有很多报告要修改

如果我可以将我的rdlc作为XmlDocument加载,我知道怎么做,但是有没有办法呢

在解决方案资源管理器中,您可以右键单击.rdlc文件并选择以选择编辑器

更新:

我正在寻找一种方法,将我的rdlc加载到xmlDocument对象中,然后在运行时编辑xml节点

以下代码段帮助您将.rdlc报告文件从resources文件夹加载到Xml文档:

using System;
using System.Windows.Forms;
using System.Xml;
using System.IO;
using System.Resources;

 private void LoadRDLCFromResources()
 {
    //Declare variables
    XmlDocument objXmlDocument = new XmlDocument();
    Byte[] byteArray;
    Stream objStream = null;
    ResourceManager resourceManager = null;

    try
    {
        // Initialize ResourceManager object
        resourceManager = new ResourceManager("your_namespace_name.Properties.Resources", GetType().Assembly);
        if (resourceManager != null)
        {
            //Load the resource file "Sample.rdlc" into ByteArray
            byteArray = (Byte[])resourceManager.GetObject("Sample");
            if (byteArray != null)
            {
                //Load this bytearray into MemoryStream
                objStream = new MemoryStream(byteArray);
                if (byteArray.Length > 0)
                {
                    //Load this stream object into XML document and  
                    //thus you get the rdlc file loaded as an XML 
                    //document. 
                    objXmlDocument.Load(objStream);

                    // Code for using this xml document as per your use
                }
            }
        }
    } 
    //MissingManifestResourceException is an exception thrown when the resource manager fails to initialize appropriately. In such case, please check the namespace name.
    catch (MissingManifestResourceException ex)
    {

        MessageBox.Show("Exception -> " + ex.Message,
           "Sample Demo", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
    catch (Exception ex)
    {
        MessageBox.Show("Exception -> " + ex.Message,
            "Sample Demo", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
    finally
    {
        // Clear the objects in finally block. This is required for memory management issues.
        // If xml document is not required further then clear it in the following manner
        if (objXmlDocument != null)
        {
            objXmlDocument.DocumentElement.RemoveAllAttributes();
            objXmlDocument.DocumentElement.RemoveAll();   

            objXmlDocument.RemoveAll();
        }
        //Clear the memory stream object 
        if (objStream != null)
        {
            objStream.Flush();
            objStream.Close();
            objStream.Dispose();
        }
        // Clear resource manager 
        resourceManager.ReleaseAllResources();
    }
}
来源:

好的! 我可以通过以下代码将rdlc作为xmlDocument加载:

Stream st = this.GetType().Assembly.GetManifestResourceStream(_NomRessourceRpt);

// convert stream to string
StreamReader reader = new StreamReader(st);
string reportDef = reader.ReadToEnd();

XmlDocument document = new XmlDocument();
document.LoadXml(reportDef);

感谢您的帮助:

如果我这样做,我必须自己编辑所有报告。我正在寻找一种方法,将我的rdlc加载到xmlDocument对象中,然后在运行时编辑xml节点。谢谢你的帮助,如果没有其他解决方案,我会这么做的。我应该意识到这就是你想要的。我更新了我的答案。再次感谢你,但我仍然有一个问题。如果my.rdlc不在Resources.resx中,则无法运行此代码。我试图用resourceManager.GetResourceSet和一个foreach来展示其中的所有内容,但是没有rdlc。我想我们已经接近目标了!使用this.GetType.Assembly.GetManifestResourceStream_NomRessourceRpt;我可以将rdlc加载到xmlDocument中。听起来不错,我继续