彩票走势图

Stimulsoft Reports.WinRT显示和保存报表[代码示例]

原创|使用教程|编辑:郝浩|2013-03-08 09:58:54.000|阅读 434 次

概述:Stimulsoft Reports.WinRT中的ViewerRT用于在WinRT中显示报表、缩放、保存、打印报表的控件。本文将展示如何加载和保存报表的代码。

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

  Stimulsoft Reports.WinRT中的ViewerRT用于在WinRT中显示报表、缩放、保存、打印报表的控件。本文将展示如何加载和保存报表的代码。

显示报表

  添加以下代码便可以显示已经渲染好的报表(*.mdc, *.mdz, *.mdx)。

XAML文件:

<Page x:Class="Demo.RT.BlankPage"
xmlns="//schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="//schemas.microsoft.com/winfx/2006/xaml"
xmlns:viewerRT="using:Stimulsoft.Report.Viewer.RT">
<viewerRT:StiViewerControl x:Name="viewerControl"/>
</Page>

 

CS文件:

namespace Demo.RT
{
public sealed partial class BlankPage : Page
    {
        #region Handlers
        async private void BlankPage_Loaded(object sender, RoutedEventArgs
e)
        {
            StorageFolder folder = Windows.Storage.KnownFolders.
DocumentsLibrary;
            StorageFile storageFile = await folder.GetFileAsync(
"SimpleList.mdc");
            StiReport report = new StiReport();
            await report.LoadDocumentAsync(storageFile);
            viewerControl.Report = report;
        }
        #endregion
        public BlankPage()
        {
            this.InitializeComponent();
            this.Loaded += BlankPage_Loaded;
        }
    }
}

 

  以下代码用于显示报表模板,即还未渲染的报表(*.mrt, *.mrz, *.mrx)。

XAML文件:

<Page x:Class="Demo.RT.BlankPage"
xmlns="//schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="//schemas.microsoft.com/winfx/2006/xaml"
xmlns:viewerRT="using:Stimulsoft.Report.Viewer.RT">
<viewerRT:StiViewerControl x:Name="viewerControl"/>
</Page>

CS文件:

namespace Demo.RT
{
public sealed partial class BlankPage : Page
{
#region Handlers
async private void BlankPage_Loaded(object sender,
RoutedEventArgs e)
{
StorageFolder folder = Windows.Storage.KnownFolders.
DocumentsLibrary;
StorageFile storageFile = await folder.GetFileAsync
("SimpleList.mrt");
StiReport report = new StiReport();
await report.LoadAsync(storageFile);
await report.RenderAsync();
viewerControl.Report = report;
}
#endregion
public BlankPage()
{
this.InitializeComponent();
this.Loaded += BlankPage_Loaded;
}
}
}

  接下来可以通过点击“打开”按钮打开已渲染的报表。

Stimulsoft Reports.WinRT显示和保存报表的代码示例

保存报表

  下面是保存报表的代码示例。

XAML文件:

<Page x:Class="Demo.RT.BlankPage"
xmlns="//schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="//schemas.microsoft.com/winfx/2006/xaml"
xmlns:viewerRT="using:Stimulsoft.Report.Viewer.RT">
<viewerRT:StiViewerControl x:Name="viewerControl"/>
</Page>

CS文件:

namespace Demo.RT
{
public sealed partial class BlankPage : Page
{
#region Handlers
async private void buttonSaveReport_Click(object sender,
RoutedEventArgs e)
         {
StiReport report = new StiReport();
StorageFolder folder = Windows.Storage.KnownFolders.
DocumentsLibrary;
StorageFile storageFile = await folder.CreateFileAsync
("Report1.mdc");
await report.SaveDocumentAsync(storageFile);
         }
#endregion
public BlankPage()
{
this.InitializeComponent();
this.Loaded += BlankPage_Loaded;
}
}
}

					
标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@cahobeh.cn

文章转载自:慧都控件网

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP