使用IE11在ReportViewer中无法使用打印按钮

时间:2013-11-20 10:29:33

标签: internet-explorer reportviewer internet-explorer-11

因此我们注意到升级到Version=10.0.0.0后,ReportViewer(IE11)中的打印按钮消失了。

这就是IE10中的样子:


在做了一些研究之后,我们发现其他人也在报告这个问题(即here),但还没有找到解决方案。
使用compability模式将是一种解决方法,但不是为客户提供可行/合适的解决方案。

有没有人弄清楚如何解决这个问题?

4 个答案:

答案 0 :(得分:4)

这几周,我们面临同样的问题。 最后我们找到了解决问题的方法,这里是步骤:

  1. 将“Report Viewer 2012 Runtime”更新为11.1.3366
  2. 将“Microsoft .Net Framework”更新为4.5.1
  3. 重启系统
  4. 我们的环境: 赢得服务器2008 r2, IIS7, ReportViewer 11

答案 1 :(得分:1)

我使用了该页面中的代码(http://msdn.microsoft.com/en-us/library/ms252091.aspx)并为此创建了一个类。您可以添加一个按钮进行寻呼并调用它。

---- Call ---------
ReportPrinter prnt = new ReportPrinter();
prnt.Print(rpt.LocalReport);

Class Code
------------    
    using Microsoft.Reporting.WebForms;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Printing;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;

namespace javaFish.blogspot.Utils
{
    /// <summary>
    /// Prints report as xps file to default printer.
    /// </summary>
    public class ReportPrinter : IDisposable
    {
        //Local variables
        private int m_currentPageIndex;
        private IList<Stream> m_streams;
        private LocalReport report = null;

        /// <summary>
        /// Routine to provide to the report renderer, in order to save an image for each page of the report.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="fileNameExtension"></param>
        /// <param name="encoding"></param>
        /// <param name="mimeType"></param>
        /// <param name="willSeek"></param>
        /// <returns></returns>    
        private Stream CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek)
        {
            Stream stream = new MemoryStream();
            m_streams.Add(stream);
            return stream;
        }

        /// <summary>
        /// Export the given report as an EMF (Enhanced Metafile) file.
        /// </summary>
        /// <param name="report"></param>
        private void Export()
        {
            string deviceInfo =
              @"<DeviceInfo>
                <OutputFormat>EMF</OutputFormat>
                <PageWidth>"+ report.GetDefaultPageSettings().PaperSize.Width.ToString()+ @"in</PageWidth>
                <PageHeight>" + report.GetDefaultPageSettings().PaperSize.Height.ToString() + @"in</PageHeight>
                <MarginTop>" + report.GetDefaultPageSettings().Margins.Top.ToString() + @"in</MarginTop>
                <MarginLeft>" + report.GetDefaultPageSettings().Margins.Left.ToString() + @"in</MarginLeft>
                <MarginRight>" + report.GetDefaultPageSettings().Margins.Right.ToString() + @"in</MarginRight>
                <MarginBottom>" + report.GetDefaultPageSettings().Margins.Bottom.ToString() + @"in</MarginBottom>
            </DeviceInfo>";
            Warning[] warnings;
            m_streams = new List<Stream>();
            report.Render("Image", deviceInfo, CreateStream,
               out warnings);
            foreach (Stream stream in m_streams)
                stream.Position = 0;
        }

        /// <summary>
        /// Handler for PrintPageEvents
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="ev"></param>
        private void PrintPage(object sender, PrintPageEventArgs ev)
        {
            Metafile pageImage = new
               Metafile(m_streams[m_currentPageIndex]);

            // Adjust rectangular area with printer margins.
            Rectangle adjustedRect = new Rectangle(
                ev.PageBounds.Left - (int)ev.PageSettings.HardMarginX,
                ev.PageBounds.Top - (int)ev.PageSettings.HardMarginY,
                ev.PageBounds.Width,
                ev.PageBounds.Height);

            // Draw a white background for the report
            ev.Graphics.FillRectangle(Brushes.White, adjustedRect);

            // Draw the report content
            ev.Graphics.DrawImage(pageImage, adjustedRect);

            // Prepare for the next page. Make sure we haven't hit the end.
            m_currentPageIndex++;
            ev.HasMorePages = (m_currentPageIndex < m_streams.Count);
        }

        /// <summary>
        /// Exports local report and tries to print
        /// </summary>
        public bool Print(LocalReport localReport)
        {
            try
            {
                report = localReport;
                Export();

                if (m_streams == null || m_streams.Count == 0)
                    throw new Exception("Error: no stream to print.");
                PrintDocument printDoc = new PrintDocument();
                if (!printDoc.PrinterSettings.IsValid)
                {
                    throw new Exception("Error: cannot find the default printer.");
                }
                else
                {
                    printDoc.PrintPage += new PrintPageEventHandler(PrintPage);
                    m_currentPageIndex = 0;
                    printDoc.Print();
                }
                return true;
            }
            catch
            {
                return false;
            }
        }

        /// <summary>
        /// Dispose resources
        /// </summary>
        public void Dispose()
        {
            if (m_streams != null)
            {
                foreach (Stream stream in m_streams)
                    stream.Close();
                m_streams = null;
            }
        }
    }
}

答案 2 :(得分:0)

确保您的SQL服务器已升级到Service Pack 2.与ie10 +和SQL Server 2008R2 RTM存在多个问题兼容性问题。

ReportViewer's Print Button Incompatible with IE 10?

The following table lists the major releases of SQL Server 2008 R2.
Release Product version
SQL Server 2008 R2 Service Pack 2   10.50.4000.0
SQL Server 2008 R2 Service Pack 1   10.50.2500.0
SQL Server 2008 R2 RTM  10.50.1600.1

Microsoft Article on Server Version

连接到SQL Server实例,然后运行以下查询:

Select @@version

答案 3 :(得分:0)

这个链接对我帮助很大。

[http://www.msigman.com/ssrs-print-icon-not-appearing-in-internet-explorer-11-not-able-to-print-reports-from-ie11/][1]

介绍了解决这个问题的两种方法:

1-安装.Net 4.5.1 [http://www.microsoft.com/en-us/download/details.aspx?id=40773][1]

OR 2-添加浏览器文件,如上所述:

  

在根目录的App_Browsers文件夹中创建一个新的浏览器文件   你的解决方案将以下文本粘贴到文件中,然后运行。   问题应该解决。

&#13;
&#13;
<browsers>
<browser id="IE11Preview" parentID="Mozilla">
<identification>
<userAgent match="Trident/(?'layoutVersion'\d+).*rv:(?'revision'(?'major'\d+)(\.(?'minor'\d+)?))" />
<userAgent nonMatch="MSIE" />
<userAgent nonMatch="IEMobile" />
</identification>
<capabilities>
<capability name="browser" value="IE" />
<capability name="layoutEngine" value="Trident" />
<capability name="layoutEngineVersion" value="${layoutVersion}" />
<capability name="extra" value="${extra}" />
<capability name="isColor" value="true" />
<capability name="majorversion" value="${major}" />
<capability name="minorversion" value="${minor}" />
<capability name="screenBitDepth" value="8" />
<capability name="type" value="IE${major}" />
<capability name="version" value="${version}" />
<capability name="isColor" value="true" />
<capability name="screenBitDepth" value="8" />
<capability name="ecmascriptversion" value="3.0" />
<capability name="jscriptversion" value="6.0" />
<capability name="javascript" value="true" />
<capability name="javascriptversion" value="1.5" />
<capability name="w3cdomversion" value="1.0" />
<capability name="ExchangeOmaSupported" value="true" />
<capability name="activexcontrols" value="true" />
<capability name="backgroundsounds" value="true" />
<capability name="cookies" value="true" />
<capability name="frames" value="true" />
<capability name="javaapplets" value="true" />
<capability name="supportsCallback" value="true" />
<capability name="supportsFileUpload" value="true" />
<capability name="supportsMultilineTextBoxDisplay" value="true" />
<capability name="supportsMaintainScrollPositionOnPostback" value="true" />
<capability name="supportsVCard" value="true" />
<capability name="supportsXmlHttp" value="true" />
<capability name="tables" value="true" />
<capability name="supportsAccessKeyAttribute" value="true" />
<capability name="preferredRenderingType" value="html5" />
<capability name="tagwriter" value="System.Web.UI.HtmlTextWriter" />
<capability name="vbscript" value="true" />
</capabilities>
</browser>
</browsers>
&#13;
&#13;
&#13;

如果问题已存在,请设置 compatibility view setting IE11