分享

请教一下导出excel的问题

credit 发表于 2016-11-15 11:56:38 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 2 5888
想请教一个问题,就是有时候需要导出的数据量很大,如果做分批次导出到同一个表的同一个sheet里面,XSSFWorkbook.write(out),会不会释放上一次缓存的数据,

已有(2)人评论

跳转到指定楼层
nextuser 发表于 2016-11-15 13:40:15


应该是没有的,楼主可以看下源码。
[mw_shl_code=java,true]/// <summary>
        /// Write out this workbook to an Outputstream.  Constructs
        /// a new POI POIFSFileSystem, passes in the workbook binary representation  and
        /// Writes it out.
        /// </summary>
        /// <param name="stream">the java OutputStream you wish to Write the XLS to</param>
        public override void Write(Stream stream)
        {
            byte[] bytes = GetBytes();
            POIFSFileSystem fs = new POIFSFileSystem();
            // For tracking what we've written out, used if we're
            //  going to be preserving nodes
            List<string> excepts = new List<string>(1);

            MemoryStream newMemoryStream = new MemoryStream(bytes);
            // Write out the Workbook stream
            fs.CreateDocument(newMemoryStream, "Workbook");

            // Write out our HPFS properties, if we have them
            WriteProperties(fs, excepts);

            if (preserveNodes)
            {
                // Don't Write out the old Workbook, we'll be doing our new one
                excepts.Add("Workbook");
                // If the file had WORKBOOK instead of Workbook, we'll Write it
                //  out correctly shortly, so don't include the old one
                excepts.Add("WORKBOOK");

                // Copy over all the other nodes to our new poifs
                CopyNodes(this.filesystem, fs, excepts);
            }
            fs.WriteFileSystem(stream);

            fs.Dispose();
            newMemoryStream.Dispose();
            bytes = null;
        }[/mw_shl_code]
回复

使用道具 举报

credit 发表于 2016-12-16 11:53:41
nextuser 发表于 2016-11-15 13:40
应该是没有的,楼主可以看下源码。
[mw_shl_code=java,true]///
        /// Write out this workb ...

确实是没有,谢谢了,换成使用csv了

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条