• <menu id="w2i4a"></menu>
  • 首頁(yè) > 慧問(wèn) > 頻道

    FastReport常見(jiàn)問(wèn)題解答

    發(fā)表于2021-07-20 回復(fù):1 查看:3725  |  

    如何為最終用戶刪除“數(shù)據(jù)”選項(xiàng)卡?

    將“ EnvironmentSettings”控件添加到您的窗體。 
    然后在調(diào)用report.Design()之前添加以下行:

    EnvironmentSettings1.DesignerSettings.Restrictions.DontCreateData = True;
    EnvironmentSettings1.DesignerSettings.Restrictions.DontEditData = True;

     如果使用DesignerControl,則應(yīng)使用以下命令:

    designerControl1.Restrictions.DontCreateData = true;
    designerControl1.Restrictions.DontEditData = true;

    這樣,數(shù)據(jù)控件將被禁用。


    如何在WPF應(yīng)用程序中使用FastReport.Net控件?

    您應(yīng)該為此使用WindowsFormsHost控件:

    0)在FastReport.dll上添加引用;

    1)如果要使用PreviewControl,則將屬性添加到Window(Page)標(biāo)記中:xmlns:fr =“ clr-namespace:FastReport.Preview; assembly = FastReport”,xmlns:fr1 =“ clr-namespace:FastReport.Design; assembly = FastReport”-if DesignerControl;

    2)將WindowsFormsHost標(biāo)記添加到您的XAML標(biāo)記中:

    <WindowsFormsHost HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="0" Grid.ColumnSpan="3">
    </WindowsFormsHost>

     3)將子級(jí)添加到WindowsFormsHost中:<fr:PreviewControl> </ fr:PreviewControl>或<fr1:Designer> </ fr1:Designer>。

    完整的標(biāo)記應(yīng)如下所示:

    <Window
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     x:Class="WpfApplication1.MainWindow"
     Title="MainWindow" Height="375.977" Width="939.258"
     xmlns:fr="clr-namespace:FastReport.Preview;assembly=FastReport">
     <Grid>
     <Grid.ColumnDefinitions>
     <ColumnDefinition Width="*"/>
     <ColumnDefinition Width="*"/>
     <ColumnDefinition Width="*"/>
     </Grid.ColumnDefinitions>
     <WindowsFormsHost HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="0" Grid.ColumnSpan="3">
     <fr:PreviewControl></fr:PreviewControl>
     </WindowsFormsHost>
     </Grid>
    </Window>


    如何以編程方式設(shè)置Format的值?

    您可以使用以下代碼在腳本或項(xiàng)目中執(zhí)行此操作:

    FastReport.Format.NumberFormat format = new FastReport.Format.NumberFormat();
    format.UseLocale = false;
    format.DecimalDigits = 2;
    format.DecimalSeparator = ".";
    format.GroupSeparator = ",";

    然后:

    textObject.Formats.Clear();
    textObject.Formats.Add(format);


    如何在MSChartObject中創(chuàng)建帶有間隙的行?

    您應(yīng)該創(chuàng)建基本的System.Windows.Forms.DataVisualization.Charting.Series對(duì)象,并在此處創(chuàng)建行。之后,應(yīng)為MSChartObject基本圖表分配創(chuàng)建的系列(MSChart1.Chart.Series.Add(series);)不要忘記在“報(bào)表”->“腳本”菜單和命名空間System.Windows.Forms中添加 System.Windows.Forms.DataVisualization.dll。 .DataVisualization.Charting。

    帶有間隙的線的示例:

    .
    .
    using System.Windows.Forms.DataVisualization.Charting;
     
    namespace FastReport
    {
     public class ReportScript
     {
     private void MSChart1_BeforePrint(object sender, EventArgs e)
     { 
     Series series = new Series("sample");
     series.ChartType = SeriesChartType.Line;
     series.BorderWidth = 2;
     series.MarkerSize = 5;
     
     series.Points.Add(new DataPoint(0, 1));
     series.Points.Add(new DataPoint(1, 2));
     DataPoint dp = new DataPoint(2, double.NaN);
     dp.IsEmpty = true;
     series.Points.Add(dp);
     series.Points.Add(new DataPoint(3, 5));
     series.Points.Add(new DataPoint(4, 8)); 
     
     MSChart1.Chart.Series.Add(series);
     
     }
     }
    }

    結(jié)果:

    ?·?è·??o?


    如何從代碼創(chuàng)建MSChartObject?

    1.創(chuàng)建新的MSChart對(duì)象,設(shè)置寬度,高度和圖例:

     MSChartObject MSChart1 = new MSChartObject();
     MSChart1.Width = 300;
     MSChart1.Height = 300;
     MSChart1.Chart.Legends.Add(new Legend() { Name = "Legend1", Title="Legend title"});

     2.創(chuàng)建ChartArea對(duì)象,設(shè)置名稱,軸標(biāo)題,并將創(chuàng)建的ChartArea分配給MSChart:

     ChartArea chartArea1 = new ChartArea();
     chartArea1.Name = "ChartArea1";
     chartArea1.Axes[0].Title = "X name";
     chartArea1.Axes[1].Title = "Y name";
     MSChart1.Chart.ChartAreas.Add(chartArea1);

    3.創(chuàng)建系列對(duì)象,設(shè)置圖表類型,邊框?qū)挾龋砑狱c(diǎn)并將系列分配給圖表:

     Series series = new Series("sample");
     series.ChartType = SeriesChartType.Line;
     series.BorderWidth = 2;
     series.Points.Add(new DataPoint(0, 1));
     series.Points.Add(new DataPoint(1, 2));
     series.Points.Add(new DataPoint(3, 5));
     series.Points.Add(new DataPoint(4, 8));
     
     MSChart1.Chart.Series.Add(series);

     4.將創(chuàng)建的MSChart分配給DataBand:

    Report report = new Report();
    report.Load("ok.frx");
    DataBand db = report.FindObject("Data1") as DataBand;
     
    MSChart1.Parent = db;

    完整的代碼段:

     MSChartObject MSChart1 = new MSChartObject();
     MSChart1.Width = 300;
     MSChart1.Height = 300;
     MSChart1.Chart.Legends.Add(new Legend() { Name = "Legend1", Title="Legend title"});
     
     ChartArea chartArea1 = new ChartArea();
     chartArea1.Name = "ChartArea1";
     chartArea1.Axes[0].Title = "X name";
     chartArea1.Axes[1].Title = "Y name";
     MSChart1.Chart.ChartAreas.Add(chartArea1); 
     
     Series series = new Series("sample");
     series.ChartType = SeriesChartType.Line;
     series.BorderWidth = 2;
     series.Points.Add(new DataPoint(0, 1));
     series.Points.Add(new DataPoint(1, 2));
     series.Points.Add(new DataPoint(3, 5));
     series.Points.Add(new DataPoint(4, 8));
     
     MSChart1.Chart.Series.Add(series);
     
     Report report = new Report();
     report.Load("ok.frx");
     DataBand db = report.FindObject("Data1") as DataBand;
     MSChart1.Parent = db;

     結(jié)果:

    ???è?¨

    如何從代碼中獲取查詢參數(shù)值?

    您應(yīng)該使用以下代碼段:

    Report.Dictionary.Connections [0] .Tables [0] .Parameters [0] .Value.ToString();


    如何將HTML格式的報(bào)告嵌入消息中并使用代碼通過(guò)電子郵件發(fā)送?

    為此使用以下代碼段:

    Report report = new Report();
     report.LoadPrepared("preparedreport.fpx");
     
     HTMLExport htmlExport = new HTMLExport()
     {
     SubFolder = false,
     Navigator = false,
     Pictures = true,
     EmbedPictures = true,
     SinglePage = true,
     Layers = true,
     HasMultipleFiles = false
     };
     EmailExport email = new EmailExport();
     
     //email mailer settings
     email.Account.Address = "Email@gmail.com";
     email.Account.Name = "Usename";
     email.Account.Host = "smtp.yandex.ru";
     email.Account.Port = 25;
     email.Account.UserName = "Email";
     email.Account.Password = "password";
     email.Account.MessageTemplate = "Test";
     email.Account.EnableSSL = true;
     
     //email addressee settings
     email.Address = "Destinationaddress@gmail.com";
     email.Subject = "Embedding of html";
     
     email.Export = htmlExport; //Set export type
     email.SendEmail(report); //Send email


    如何在構(gòu)建或查看報(bào)告時(shí)關(guān)閉ProgressForm?

    您可以在EnvironmentSettings中關(guān)閉ProgressForm:

    Report report = new Report(); 
    report.LoadPrepared(“ 1.fpx”); 
    EnvironmentSettings s = new EnvironmentSettings(); 
    s.ReportSettings.ShowProgress = false; 
    

    report.Show();如何從代碼中獲取查詢參數(shù)值?

    0個(gè)回答

    打破零回復(fù)...

    回復(fù)

    登錄 慧都網(wǎng)發(fā)表評(píng)論

    掃碼咨詢


    添加微信 立即咨詢

    電話咨詢

    客服熱線
    023-68661681

    TOP
    三级成人熟女影院,欧美午夜成人精品视频,亚洲国产成人乱色在线观看,色中色成人论坛 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();