silverlight   发布时间:2022-05-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Silverlight4:Devexpress Report大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

我不知道在silvelright中对于report报表有什么好的解决方案,除了devexpress,telerik这些第3方的公司开发的silverlight 报表控件之外。我在google疯狂检索,没有找到像样的开源的解决方案。在一番比较群横还是选择devexpress的报表控件。 下面的内容就是利用devexpress report来完成一个报表: 具体来将有2种方式 1)报表和silverl

我不知道在silvelright中对于report报表有什么好的@L_489_0@案,除了devexpress,telerik这些第3方的公司开发的silverlight 报表控件之外。我在google疯狂检索,没有找到像样的开源的@L_489_0@案。在一番比较群横还是选择devexpress的报表控件。

下面的内容就是利用devexpress report来完成一个报表:

具体来将有2种方式

1)报表和silverlight app在2个不同windows 窗口

2)报表嵌在silverlight page中

无论哪种方式都是看,具体的需求。

首先在silverlight host web里面加入Report.svc:

/// <sumMary>
/// IReportservice
/// </sumMary>
[serviceContract]
public interface IReportservice : DevExpress.XtraReports.service.IReportservice {
    [OperationContract]
    DocumentId GetReportsByName(String reportName);
}

/// <sumMary>
/// Reportservice
/// </sumMary>
[AspNetCompatibilityrequirements(requirementsMode = AspNetCompatibilityrequirementsMode.Allowed)]
public class Reportservice : DevExpress.XtraReports.service.Reportservice,IReportservice {
    public Reportservice() {            
    }

     const String filePath = "~/Reports";      
       public byte[] GetReportFile(String path)
    {
        return File.ReadAllBytes(path);
    }

    private static String GetAbsulotePath(String path)
    {
        return "\\" + path;
    }
    public DocumentId GetReportsByName(String reportName)
    {
        //XtraReport report = new XtraReport();
        String path=httpContext.Current.Server.MapPath(filePath + "//" + reportName+".repx");
        byte[] bytes=GetReportFile(path);
        XtraReport report = XtraReport.FromStream(new MemoryStream(bytes),truE);                    
        //report.Datasource = GetData();
        DocumentId doc = StartBuild(report);
        return doc;
       
    }
}

Silverlight Project 中的页面:xaml

<Grid x:Name="LayoutRoot">
       <StackPanel Orientation="Vertical">
           <Button Content="button" Width="50" Height="20" Click="Button_Click"></Button>
                  <my:DocumentPreview  NAME="documentPreview1" />          
       </StackPanel>

   </Grid>

放置一个DocumentPreView,当button点击,将报表通过DocumentPreView渲染,mainPage.cs

private void Button_Click(object sender,RoutedEventArgs E)
        {
            Reportservice.ReportserviceClient client = new ReportserviceClient();
            client.GetReportsByNameCompleted += new EventHandler<GetReportsByNameCompletedEventArgs>(client_GetReportsByNameCompleted);
            client.GetReportsByNameAsync("XtraReport1");
           
        }

        void client_GetReportsByNameCompleted(object sender,GetReportsByNameCompletedEventArgs E)
        {
            ReportPreviewmodel previewmodel = new ReportPreviewmodel(serviceUri.AbsoluteUri);          
            previewmodel.ProcessDocument(e.Result);
            documentPreview1.Model = previewmodel; 
            //throw new NotImplementedException();
        }


const String RelativeserviceUrl = "/Reportservice.svc";    
static Uri serviceAbsoluteUri;
internal static Uri serviceUri
{
    get
    {
        if (serviceAbsoluteUri == null)
            serviceAbsoluteUri = new Uri(Application.Current.Host.source,".." + RelativeserviceUrl);
        return serviceAbsoluteUri;
    }
}

剩下要注意的是serviceReference.ClientConfig:

<endpoint address="http://localhost:53609/ReportService.svc%22
             binding="basichttpBinding" bindingConfiguration="BasichttpBinding_IReportservice"
             contract="Reportservice.IReportservice" name="BasichttpBinding_IReportservice" />

contract是 Reportservice.IReportservice

这样就是一个简单的devexpress report

环境:visual studio 2010,silverlight4 DevExpress v10.1

大佬总结

以上是大佬教程为你收集整理的Silverlight4:Devexpress Report全部内容,希望文章能够帮你解决Silverlight4:Devexpress Report所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。