使用 SQL Server Reporting Services 2008 (SP1) 创建使用 .jpg 图像的报表时,有时在将报表导出到 word 时会出现以下错误。
Index was outside the bounds of the array.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Exception: Index was outside the bounds of the array.
最佳答案
与 Microsoft 支持人员(一位名叫 Mikael Ljunghorn 的乐于助人的小伙子)讨论过这个问题,这似乎与您在报告中使用的 .jpg 图像是否使用“渐进”编码进行编码有关。
为防止发生这种情况,请尽量避免在报告中使用渐进式编码的 .jpg 图像。
Mikael 还建议使用以下解决方法将 jpg 图像转换为 png 以避免 Word 中的转换问题:
1)
通过“报告”>“报告属性”>“代码”窗口添加此自定义代码块。
函数 ConvertToPNG(ByVal bytes As Byte()) As Byte() Dim inStream 作为新的 System.IO.MemoryStream(bytes) 调暗 bmp 作为新的 System.Drawing.Bitmap(inStream) 将 outStream 调暗为新 System.IO.MemoryStream() bmp.Save(outStream,System.Drawing.Imaging.ImageFormat.PNG) 返回outStream.GetBuffer() 结束函数
2)
在此调用中包装数据库图像值表达式:=Code.ConvertToPNG(Fields!ImageBlobField.Value)
关于sql-server-2008 - 当我将包含 .jpg 图像的报表导出到 MS Word 时,为什么有时会在 Reporting Services 中出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1443208/