翻譯|使用教程|編輯:吉煒煒|2025-03-17 14:11:20.750|閱讀 94 次
概述:在本文中,我們將探討 Stimulsoft 與WinUI項目的集成。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
Stimulsoft Ultimate (原Stimulsoft Reports.Ultimate)是用于創建報表和儀表板的通用工具集。該產品包括用于WinForms、ASP.NET、.NET Core、JavaScript、WPF、PHP、Java和其他環境的完整工具集。無需比較產品功能,Stimulsoft Ultimate包含了所有內容!
WinUI是適用于 Windows 桌面應用程序的用戶界面 (UI) 框架,包括使用 C# 和 .NET 的托管應用程序,以及使用 C++ 和 Win32 API 的本機應用程序。WinUI 3 使用最新的 UI 模式提供一致、直觀且易于訪問的體驗。Stimulsoft 沒有專門針對WinUI 的解決方案;但是,要嵌入報告系統,您可以使用Stimulsoft.Reports.Web.NetCore組件,如果需要集成分析系統,則可以使用Stimulsoft.Dashboards.Web.NetCore組件。重要提示!
.NET Core 的報告工具允許您創建任何復雜程度的報告,從標準發票到具有參數、交互式排序和向下鉆取功能的復雜文檔。但是,WinUI框架的本機可視化組件、報告查看器和報告設計器不可用,并且 .NET Core 包中的組件可能會表現得不可預測。這是由于WinUI框架本身的某些特性造成的。因此,目前我們不建議將查看器或設計器嵌入到WinUI項目中。
<?xml version="1.0" encoding="utf-8"?> <Window ? ? ? x:Class="App1.MainWindow" ? ? ? xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" ? ? ? xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" ? ? ? xmlns:local="using:App1" ? ? ? xmlns:d="http://schemas.microsoft.com/expression/blend/2008" ? ? ? xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" ? ? ? mc:Ignorable="d" ? ? ? Title="App1"> ? ? ? ? <Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch"> ? ? ? ? ? ? ? ? <Grid.RowDefinitions> ? ? ? ? ? ? ? ? ? ? ? ? <RowDefinition Height="100" /> ? ? ? ? ? ? ? ? ? ? ? ? <RowDefinition Height="*" /> ? ? ? ? ? ? ? ? </Grid.RowDefinitions> ? ? ? ? ? ? ? ? <Button x:Name="button" HorizontalAlignment="Center" VerticalAlignment="Center" ? ? ? ? ? ? ? ? ? ? ? Content="Click To Show Report" ? ? ? ? ? ? ? ? ? ? ? Click="Button_Click" /> ? ? ? ? ? ? ? ? <WebView2 x:Name="webView" Grid.Row="1" />> ? ? ? ? </Grid> </Window>
using System; using System.IO; using System.Reflection; using Microsoft.UI.Xaml; using Stimulsoft.Report; using Stimulsoft.Report.Export; // To learn more about WinUI, the WinUI project structure, // and more about our project templates, see: //aka.ms/winui-project-info. namespace App1 { ? ? ? ? /// <summary> ? ? ? ? /// An empty window that can be used on its own or navigated to within a Frame. ? ? ? ? /// </summary> ? ? ? ? public sealed partial class MainWindow : Window ? ? ? ? { ? ? ? ? ? ? ? ? public MainWindow() ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? this.InitializeComponent(); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? private async void Button_Click(object sender, RoutedEventArgs e) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? button.Content = "Clicked"; ? ? ? ? ? ? ? ? ? ? ? ? // Load the report ? ? ? ? ? ? ? ? ? ? ? ? var report = new StiReport(); ? ? ? ? ? ? ? ? ? ? ? ? var reportStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("App1.Assets.Christmas.mrt"); ? ? ? ? ? ? ? ? ? ? ? ? report.Load(reportStream); ? ? ? ? ? ? ? ? ? ? ? ? // Export the report to PDF ? ? ? ? ? ? ? ? ? ? ? ? report.Render(); ? ? ? ? ? ? ? ? ? ? ? ? using var pdfStream = new MemoryStream(); ? ? ? ? ? ? ? ? ? ? ? ? report.ExportDocument(StiExportFormat.Pdf, pdfStream, new StiPdfExportSettings()); ? ? ? ? ? ? ? ? ? ? ? ? var pdfString = Convert.ToBase64String(pdfStream.ToArray()); ? ? ? ? ? ? ? ? ? ? ? ? await webView.EnsureCoreWebView2Async(); ? ? ? ? ? ? ? ? ? ? ? ? // Display the PDF in a WebView2 control ? ? ? ? ? ? ? ? ? ? ? ? webView.NavigateToString( ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? @$"<html><head></head><body><div><object type=""application/pdf"" width=""100%"" height=""100%"" data=""data:application/pdf;base64,{pdfString}""></object></div></body></html>"); ? ? ? ? ? ? ? ? } ? ? ? ? } }
因此,在開發空白應用程序、打包(桌面版 WinUI 3)應用程序時,無需集成報告查看器或設計器即可使用報告和數據分析系統。有關使用 .NET Core Stimulsoft 的更多詳細信息,請參閱文檔。Stimulsoft.Reports.Web.NetCore的激活可通過Reports.WEB訂閱獲得,而Stimulsoft.Dashboards.Web.NetCore則需要Dashboards.WEB訂閱。此外,可以在網上商店購買 用于跨多個平臺報告和分析的綜合解決方案Stimulsoft Ultimate 。
---------------------------------------------------------------------------
關于慧都科技:
慧都科技是專注軟件工程、智能制造、石油工程三大行業的數字化解決方案服務商。在軟件工程領域,我們提供開發控件、研發管理、代碼開發、部署運維等軟件開發全鏈路所需的產品,提供正版授權采購、技術選型、個性化維保等服務,幫助客戶實現技術合規、降本增效與風險可控。慧都科技是Stimulsoft的在中國區的合作伙伴,Stimulsoft作為圖表報表領域的優秀產品,幫助企業實現輕松構建高性能的表格報告及圖表。
下載|體驗更多Stimulsoft產品,請咨詢,或撥打產品熱線:023-68661681
加入圖表報表技術交流QQ群(740060302),與更多小伙伴一起探討提升開發技能。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都網