原創(chuàng)|使用教程|編輯:郝浩|2013-03-08 09:58:54.000|閱讀 475 次
概述:Stimulsoft Reports.WinRT中的ViewerRT用于在WinRT中顯示報表、縮放、保存、打印報表的控件。本文將展示如何加載和保存報表的代碼。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
Stimulsoft Reports.WinRT中的ViewerRT用于在WinRT中顯示報表、縮放、保存、打印報表的控件。本文將展示如何加載和保存報表的代碼。
添加以下代碼便可以顯示已經(jīng)渲染好的報表(*.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; } } }
接下來可以通過點(diǎn)擊“打開”按鈕打開已渲染的報表。
下面是保存報表的代碼示例。
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; } } }
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都控件網(wǎng)