找回密码
 立即注册

QQ登录

只需一步,快速开始

421793460

注册会员

7

主题

28

帖子

157

积分

注册会员

积分
157

活字格认证

421793460
注册会员   /  发表于:2017-9-20 22:10  /   查看:3772  /  回复:6
本帖最后由 421793460 于 2017-9-21 21:13 编辑

导出Excel时报错:Error saving Excel File:测试时,Spread1中有:品名|条码|数量|金额|图片列
                                                               图片大小:1.69MB .jpg格式的任意这样大的图片都可测试,
使用fpSpread1.SaveExcel(s, FarPoint.Excel.ExcelSaveFlags.NoFlagsSet)方法导的.
共有4行数据,每行都是同一张图片,共4张,能正常导出excel表单,但是导出后的xls文件高达64MB左右了也太大了,这是什么原因呢?
如果有5行及以上就报错:Error saving Excel File
说明是导出时,图片总大小=5x1.69MB=8.45MB,再加上几列或更多列的文本信息,导出数据量也加上,就造成这样的错误了.
看本论坛其它网友碰到这样的情况:
http://gcdn.gcpowertools.com.cn/ ... d=8695&topicid=8695
http://gcdn.gcpowertools.com.cn/ ... icid=16317&page=end
估计不只是图片,如果无图片列数据量超过8MB左右就会报这样的错误,麻烦解决下;

QQ截图20170920215358.png
QQ截图20170920214511.png
有关调用实时(JIT)调试而不是此对话框的详细信息,
请参见此消息的结尾。

************** 异常文本 **************
System.ApplicationException: Error saving Excel file ---> System.OutOfMemoryException: 引发类型为“System.OutOfMemoryException”的异常。
   在 System.IO.MemoryStream.set_Capacity(Int32 value)
   在 System.IO.MemoryStream.EnsureCapacity(Int32 value)
   在 System.IO.MemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count)
   在 System.IO.BinaryWriter.Write(Byte[] buffer)
   在 FarPoint.Excel.OfficeArtBlipPNG.Write(BinaryWriter writer)
   在 FarPoint.Excel.OfficeArtBStoreContainer.Write(BinaryWriter writer)
   在 FarPoint.Excel.OfficeArtDggContainer.Write(BinaryWriter writer)
   在 as.f()
   在 as.a(Stream A_0, ExcelSaveFlags A_1)
   在 FarPoint.Excel.ExcelFileHandler.a(Stream A_0, ExcelSaveFlags A_1, String A_2)
   在 FarPoint.Excel.ExcelFileHandler.Save(Stream stream, ExcelSaveFlags saveFlags, String password)
   在 ci.a(Stream A_0, ExcelSaveFlags A_1, String A_2)
   在 c9.a(String A_0, Stream A_1, ExcelSaveFlags A_2, ExcelWarningList A_3, String A_4)
   --- 内部异常堆栈跟踪的结尾 ---
   在 c9.a(String A_0, Stream A_1, ExcelSaveFlags A_2, ExcelWarningList A_3, String A_4)
   在 FarPoint.Win.Spread.FpSpread.SaveExcel(Stream stream, ExcelSaveFlags saveFlags, ExcelWarningList warningList, String password)
   在 FarPoint.Win.Spread.FpSpread.SaveExcel(Stream stream, ExcelSaveFlags saveFlags, String password)
   在 FarPoint.Win.Spread.FpSpread.SaveExcel(Stream stream, ExcelSaveFlags saveFlags)
   在 ExcelExport_Click(Object sender, EventArgs e) 位置 C:\Users\Administrator\Desktop\myPrint.vb:行号 1828
   在 System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
   在 System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
   在 System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
   在 System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
   在 System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
   在 System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
   在 System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
   在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   在 System.Windows.Forms.Control.WndProc(Message& m)
   在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   在 System.Windows.Forms.ToolStrip.WndProc(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

************** 已加载的程序集 **************


6 个回复

倒序浏览
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2017-9-21 09:05:19
沙发
这个是导出内存溢出了,您用的哪个版本的spread,可否发个Demo出来
回复 使用道具 举报
421793460
注册会员   /  发表于:2017-9-21 09:28:09
板凳
5.0的版本载入5行图片时从数据库取得的,不方便发demo: dsImg.Tables("itemPic").Rows(0).Item("FImage")
表格取值时:
                                buffer = CType(dsImg.Tables("itmPic").Rows(0).Item("FImage"), Byte())
                                memoryStream = New System.IO.MemoryStream(buffer)
                                Dim imgct As New FarPoint.Win.Spread.CellType.ImageCellType()
                                Dim image As System.Drawing.Image = New System.Drawing.Image.Bitmap(memoryStream)
                                .Cells(1, 0).CellType = imgct
                                .Cells(1, 0).Value = image
FpSpread1.SaveExcel(s, FarPoint.Excel.ExcelSaveFlags.NoFlagsSet)方法导出的,也就这两段
回复 使用道具 举报
421793460
注册会员   /  发表于:2017-9-21 11:02:19
地板
本帖最后由 421793460 于 2017-9-21 16:58 编辑

谢谢!
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2017-9-21 15:49:58
5#
您好,我这里用新版本测试了是没有问题的,5已经是很老的版本了,建议您升级到最新版
回复 使用道具 举报
421793460
注册会员   /  发表于:2017-9-21 16:12:21
6#
谢谢版主,能帮忙看下我写法中载入图片时,代码对不对呢?帮忙纠正下吧,当前没有机会升级到新版.
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2017-9-21 16:36:55
7#
代码没有问题,我这边直接运行您的代码都是没有问题的。可能是老版本性能上的问题。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部