none
报表打印 RRS feed

  • 问题

  • 在VS11的工具栏里,找不到关于报表打印的button。菜单栏里也没有。

    我想输出打印一个word文档。如何操作?

    2012年5月27日 2:46

答案

  • 您好!

    在Metro环境下,目前VS11没有直接提供专门的Report Control。
    请参考 Printing 和样例程序 Metro style app Print Sample
    以下是样例代码,供你参考。

    Windows.Graphics.Printing.PrintManager printManager;
    Windows.UI.Xaml.Printing.PrintDocument printDocument;
    ......
    printManager = Windows.Graphics.Printing.PrintManager.GetForCurrentView();
    printManager.PrintTaskRequested += PrintTaskRequested;
    ......
    // Create the print task when requested.
    private void PrintTaskRequested(Windows.Graphics.Printing.PrintManager sender,
                                    Windows.Graphics.Printing.PrintTaskRequestedEventArgs e)
    {
        Windows.Graphics.Printing.PrintTask printTask =
            e.Request.CreatePrintTask("Print Samples", PrintTaskSourceRequested);
    }
    
    // Supply the print source to the print task.
    private void PrintTaskSourceRequested(Windows.Graphics.Printing.PrintTaskSourceRequestedArgs e)
    {
        e.SetSource(printDocument.DocumentSource);
    }
    


    Best wishes,


    Robin [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    2012年5月27日 4:20
    版主

全部回复

  • 您好!

    在Metro环境下,目前VS11没有直接提供专门的Report Control。
    请参考 Printing 和样例程序 Metro style app Print Sample
    以下是样例代码,供你参考。

    Windows.Graphics.Printing.PrintManager printManager;
    Windows.UI.Xaml.Printing.PrintDocument printDocument;
    ......
    printManager = Windows.Graphics.Printing.PrintManager.GetForCurrentView();
    printManager.PrintTaskRequested += PrintTaskRequested;
    ......
    // Create the print task when requested.
    private void PrintTaskRequested(Windows.Graphics.Printing.PrintManager sender,
                                    Windows.Graphics.Printing.PrintTaskRequestedEventArgs e)
    {
        Windows.Graphics.Printing.PrintTask printTask =
            e.Request.CreatePrintTask("Print Samples", PrintTaskSourceRequested);
    }
    
    // Supply the print source to the print task.
    private void PrintTaskSourceRequested(Windows.Graphics.Printing.PrintTaskSourceRequestedArgs e)
    {
        e.SetSource(printDocument.DocumentSource);
    }
    


    Best wishes,


    Robin [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    2012年5月27日 4:20
    版主
  • 也可以采用一些第三方控件,已经有可以在WinRT下使用的了.
    2012年5月27日 5:13