一次大数据量导出优化--借助xml导出xls、xlsx文件

专项1.CCS代码补全与快捷键优化全攻略 本文全面解析CCS开发环境的代码补全功能与快捷键优化技巧,包括内容辅助触发机制、快捷键自定义配置、编码效率提升方法等实用内容。通过详细步骤指导开发者优化CCS配置,实现高效的代码自动补全和个性化快捷键设置,显著提升嵌入式开发效率。 阅读详情

最近遇到一个问题,线上生产环境某个功能导出数据到excel文件非常缓慢,几万数据导十多分钟都导不出来,导出慢的原因一是主表A数据量太大,接近2亿,另外里面部分数据来自于另外一张表B,B表也是几千万的数据量,数据库层面能做的优化已经做了,视图、索引这些工具都上了(没有分表是一开始项目设计阶段就没考虑,后面也没有专人维护,是另外一段故事了,这里不展开描述),但是依旧很慢,那就只能改导出代码了。

项目原来使用的是jxl来导出,生成的是xls格式Excel文件,这是旧版本的Excel文件,缺点有两点:一是单sheet页数据量小,只有6万多,二是文件太大,同等数据量下,xlsx格式的比xls格式的文件小4倍。一番搜索后,发现了POI自3.8版本后新加了一个SXSSFWorkbook类,可以处理大数据量的导出,并且内存占用不高,下面是一个小demo,写入10万行数据花费11065ms,文件大小14M不到,可以说很高效了。

package exceltest;

import java.io.FileOutputStream;

import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellUtil;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class SXSSFWorkbookTest {

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		Excel2007AboveOperate();
		long end = System.currentTimeMillis();
		System.out.println("花费:"+(end-start));//10万数据花费:11065
	}
	
	public static void Excel2007AboveOperate() {
        XSSFWorkbook workbook1 = new XSSFWorkbook();
        SXSSFWorkbook sxssfWorkbook = new SXSSFWorkbook(workbook1, 100);
		for (int i = 0; i < 10; i++) {
        	sxssfWorkbook.createSheet();
        	sxssfWorkbook.setSheetName(i, "第"+i+"页");
        	Sheet first = sxssfWorkbook.getSheetAt(i);
            for (int j = 0; j < 10000; j++) {
                Row row = first.createRow(j);
                for (int k = 0; k < 11; k++) {
                    if(j == 0) {
                        // 首行
                        row.createCell(k).setCellValue("column" + k);
                    } else {
                        // 数据
                        if (k == 0) {
                            CellUtil.createCell(row, k, String.valueOf(j));
                        } else
                            CellUtil.createCell(row, k, String.valueOf(Math.random()));
                    }
                }
            }
        }
        FileOutputStream out;
		try {
			out = new FileOutputStream("F:\\workbook666.xlsx");
			sxssfWorkbook.write(out);
	        out.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}

以为故事到这里就结束了,然而事情并没有那么简单!生产环境有个包集成了POI的代码,也可以用SXSSFWorkbook这个nb的类,但是会报错java.lang.RuntimeException: Provider for class javax.xml.stream.XMLEventFactory cannot be created,查找一番下来,有说缺少依赖包的,有说jdk版本低云云,单独引用最新的POI包,依旧是报错,怀疑是集成包里的poi代码缺少了一些东西,至于是什么无从考量,只能另辟蹊径来解决这个导出问题了,只要是依赖POI包的方法都不行,只有找到不依赖POI包却依然能导出excel文件方法才行!

又是一番寻找,看到了一篇博客,讲的是xls文件的本质其实是一个xml文件,可以通过手动拼接的方式来生成一个符合xls格式的xml文件,原博客文章暂时没找到,如果原作者看到可以留言提醒下。直接上demo代码。

package exceltest;

import java.io.BufferedOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Xml2ExcelTest {

	public static void main(String[] args) {
		test2();
	}
	
	
	public static void test2() {
		StringBuffer sb = new StringBuffer();
		File file = new File("F://testxml2xls666.xls");
        try {
			DataOutputStream rafs = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
			sb.append("<?xml version=\"1.0\"?>\n");
			sb.append("<?mso-application progid=\"Excel.Sheet\"?>\n");
			sb.append("<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\"\n");
			sb.append("  xmlns:o=\"urn:schemas-microsoft-com:office:office\"\n");
			sb.append(" xmlns:x=\"urn:schemas-microsoft-com:office:excel\"\n");
			sb.append(" xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\"\n");
			sb.append(" xmlns:html=\"http://www.w3.org/TR/REC-html40\">\n");
			sb.append(" <Styles>\n");
			sb.append("  <Style ss:ID=\"Default\" ss:Name=\"Normal\">\n");
			sb.append("   <Alignment ss:Vertical=\"Center\"/>\n");
			sb.append("   <Borders/>\n");
			sb.append("   <Font ss:FontName=\"宋体\" x:CharSet=\"134\" ss:Size=\"12\"/>\n");
			sb.append("   <Interior/>\n");
			sb.append("   <NumberFormat/>\n");
			sb.append("   <Protection/>\n");
			sb.append("  </Style>\n");
			sb.append(" </Styles>\n");
            
            int maxRow = 10;
            int maxCol = 10;
            for (int i = 0; i < 5; i++) {
            	sb.append("<Worksheet ss:Name=\"第").append(i).append("页\">\n");  
                sb.append("<Table ss:ExpandedColumnCount=\"").append(maxRow).append("\" ss:ExpandedRowCount=\"");
                sb.append(maxCol).append("\" x:FullColumns=\"1\" x:FullRows=\"1\">\n");
                for (int j = 0; j < maxRow; j++) {
                	sb.append("<Row>\n");
                	sb.append("<Cell><Data ss:Type=\"String\">").append("还好").append(i).append("</Data></Cell>\n");  
                    sb.append("<Cell><Data ss:Type=\"String\">").append(String.valueOf(Math.random())).append("</Data></Cell>\n");  
                    sb.append("<Cell><Data ss:Type=\"String\">").append(String.valueOf(Math.random())).append("</Data></Cell>\n");  
                    sb.append("<Cell><Data ss:Type=\"String\">").append(String.valueOf(Math.random())).append("</Data></Cell>\n");  
                    sb.append("<Cell><Data ss:Type=\"String\">").append(String.valueOf(Math.random())).append("</Data></Cell>\n");  
                    sb.append("<Cell><Data ss:Type=\"String\">").append(String.valueOf(Math.random())).append("</Data></Cell>\n");  
                    sb.append("<Cell><Data ss:Type=\"String\">").append(String.valueOf(Math.random())).append("</Data></Cell>\n");  
                    sb.append("<Cell><Data ss:Type=\"String\">").append(String.valueOf(Math.random())).append("</Data></Cell>\n");  
                    sb.append("<Cell><Data ss:Type=\"String\">").append(String.valueOf(Math.random())).append("</Data></Cell>\n");  
                    sb.append("<Cell><Data ss:Type=\"String\">").append(String.valueOf(Math.random())).append("</Data></Cell>\n");  
                    sb.append("</Row>\n");
                }  
                sb.append("</Table>\n");
                sb.append("<WorksheetOptions xmlns=\"urn:schemas-microsoft-com:office:excel\">\n");  
                sb.append("<ProtectObjects>False</ProtectObjects>\n");  
                sb.append("<ProtectScenarios>False</ProtectScenarios>\n");  
                sb.append("</WorksheetOptions>\n");
                sb.append("</Worksheet>\n");
                rafs.write(sb.toString().getBytes());
                rafs.flush();
                sb = null;
                sb = new StringBuffer();
            }
			sb.append("</Workbook>\n");  
			rafs.write(sb.toString().getBytes());  
            rafs.flush();
            rafs.close();  
        } catch (FileNotFoundException e) {  
            e.printStackTrace();  
        } catch (IOException e) {  
            e.printStackTrace();  
        }  
	}

}

demo可行,拿正式数据做测试,10万数据可以正常导出,速度比之前通过jxl导出快,但是有个缺点很明显,就是文件太大了,如果上生产,那文件大小估计得按G来算,这个方法也无法胜任啊!但是却提供了一种思路,既然xls文件能通过xml文件间接得到,那么xlsx文件是否也可行?想到就干!

又是一番查找,找到了一半的答案,喜忧参半吧!喜的是这个思路行得通,xlsx文件其实是一个压缩文件,可以将后缀改为zip解压,里面包含了很多的xml文件,可以用多线程逐个击破,同时解决写入和效率问题,大家可以在自己电脑上试下,你会发现新大陆的。忧的是里面每个单元格值不是明文,是键值对,需要准备一个很大的数据结构来存储。于是将本地新建的xlsx文件和通过代码生成的xlsx文件做个了比较,代码生成的xml文件里是直接放的明文,难道是我本地Office版本太高了?可能是吧,问题暂且放一边,先把demo跑通过才是正事。

先看下解压出来的文件结构:

_rels/.rels

docProps/app.xml
docProps/core.xml

xl/_rels/workbook.xml.rels
xl/worksheets/sheet1.xml
......
xl/worksheets/sheetn.xml
xl/sharedStrings.xml
xl/styles.xml
xl/workbook.xml

[Content_Types].xml

_rels/.rels文件内容是固定的,可以直接写。

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
	<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
	<Relationship Id="rId1" Target="xl/workbook.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"/>
	<Relationship Id="rId2" Target="docProps/app.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"/>
	<Relationship Id="rId3" Target="docProps/core.xml" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"/>
	</Relationships>

docProps/app.xml文件内容是固定的,可以直接写。

<?xml version="1.0" encoding="UTF-8"?>
	<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"><Application>Apache POI</Application></Properties>

docProps/core.xml文件里面需要注意下创建时间,这个时间格式需要特殊处理下。

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
	<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<dcterms:created xsi:type="dcterms:W3CDTF">2021-12-16T12:10:02Z</dcterms:created>
	<dc:creator>Apache POI</dc:creator>
	</cp:coreProperties>

xl/sharedStrings.xml文件内容是固定的,可以直接写。

<?xml version="1.0" encoding="UTF-8"?>
	<sst count="0" uniqueCount="0" xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"/>

xl/styles.xml样式文件,需要自定义样式的可以提前通过代码生成。

<?xml version="1.0" encoding="UTF-8"?>
	<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><numFmts count="0"/><fonts count="1"><font><sz val="11.0"/><color indexed="8"/><name val="Calibri"/><family val="2"/><scheme val="minor"/></font></fonts><fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="darkGray"/></fill></fills><borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/></cellXfs></styleSheet>

xl/workbook.xmlsheet页的信息文件,每个sheet页都有一个id,是一一对应的关系。name是表名,可以自定义,sheetId从1开始,r:id从rId3开始。

<?xml version="1.0" encoding="UTF-8"?>
<workbook xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"      xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
<workbookPr date1904="false"/>
<bookViews>
  <workbookView activeTab="0"/>
</bookViews>
<sheets>
  <sheet sheetId="1" r:id="rId3" name="第0页"/>
  <sheet sheetId="2" r:id="rId4" name="第1页"/>
  <sheet sheetId="3" r:id="rId5" name="第2页"/>
  <sheet sheetId="4" r:id="rId6" name="第3页"/>
  <sheet sheetId="5" r:id="rId7" name="第4页"/>
  <sheet sheetId="6" r:id="rId8" name="第5页"/>
  <sheet sheetId="7" r:id="rId9" name="第6页"/>
  <sheet sheetId="8" r:id="rId10" name="第7页"/>
  <sheet sheetId="9" r:id="rId11" name="第8页"/>
  <sheet sheetId="10" r:id="rId12" name="第9页"/>
</sheets>
</workbook>

xl/_rels/workbook.xml.relssheet的依赖文件信息,rId1和rId2都是固定的,从rId3开始对应创建的sheet页文件路径。

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Id="rId1" Target="sharedStrings.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings"/>
<Relationship Id="rId2" Target="styles.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"/>
<Relationship Id="rId3" Target="worksheets/sheet1.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"/>
<Relationship Id="rId4" Target="worksheets/sheet2.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"/>
<Relationship Id="rId5" Target="worksheets/sheet3.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"/>
<Relationship Id="rId6" Target="worksheets/sheet4.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"/>
<Relationship Id="rId7" Target="worksheets/sheet5.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"/>
<Relationship Id="rId8" Target="worksheets/sheet6.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"/>
<Relationship Id="rId9" Target="worksheets/sheet7.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"/>
<Relationship Id="rId10" Target="worksheets/sheet8.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"/>
<Relationship Id="rId11" Target="worksheets/sheet9.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"/>
<Relationship Id="rId12" Target="worksheets/sheet10.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"/>
</Relationships>

[Content_Types].xml汇总文件,里面包含了xlsx文件依赖的相关xml文件信息

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
<Default ContentType="application/vnd.openxmlformats-package.relationships+xml" Extension="rels"/>
<Default ContentType="application/xml" Extension="xml"/>
<Override ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml" PartName="/docProps/app.xml"/>
<Override ContentType="application/vnd.openxmlformats-package.core-properties+xml" PartName="/docProps/core.xml"/>
<Override ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml" PartName="/xl/sharedStrings.xml"/>
<Override ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml" PartName="/xl/styles.xml"/>
<Override ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml" PartName="/xl/workbook.xml"/>
<Override ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" PartName="/xl/worksheets/sheet1.xml"/>
<Override ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" PartName="/xl/worksheets/sheet2.xml"/>
<Override ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" PartName="/xl/worksheets/sheet3.xml"/>
<Override ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" PartName="/xl/worksheets/sheet4.xml"/>
<Override ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" PartName="/xl/worksheets/sheet5.xml"/>
<Override ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" PartName="/xl/worksheets/sheet6.xml"/>
<Override ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" PartName="/xl/worksheets/sheet7.xml"/>
<Override ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" PartName="/xl/worksheets/sheet8.xml"/>
<Override ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" PartName="/xl/worksheets/sheet9.xml"/>
<Override ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" PartName="/xl/worksheets/sheet10.xml"/>
</Types>

xl/worksheets/sheet1.xmlsheet页数据文件,其中第一个sheet页是默认选中打开的sheet页,会加上tabSelected="true"属性,只能在其中一个xml文件里设置,不能给多个sheet页xml文件设置。行号从1开始,列号从大写的英文字母加数字(也是从1开始)组成。cols标签里的col标签是设置列宽,列号通过min="1" max="1"这两个标签定义,也是从1开始。合并单元格使用<mergeCells></mergeCells>标签,跟在</sheetData>标签后面,比如想要合并A1到D1,可以这样写<mergeCells><mergeCell ref="A1:D1"/></mergeCells>。

<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<worksheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">
<dimension ref=\"A1\"/>
<sheetViews><sheetView workbookViewId=\"0\" tabSelected=\"true\"/></sheetViews>
<sheetFormatPr defaultRowHeight=\"15.0\"/>
<cols>
<col min="1" max="1" width="8.71875" customWidth="true"/>
</cols>
<sheetData>
<row r="1">
<c r=\"A1\" t=\"inlineStr\"><is><t>column0</t></is></c>
<c r=\"B1\" t=\"inlineStr\"><is><t>column1</t></is></c>
<c r=\"C1\" t=\"inlineStr\"><is><t>column2</t></is></c>
<c r=\"D1\" t=\"inlineStr\"><is><t>column3</t></is></c>
<c r=\"E1\" t=\"inlineStr\"><is><t>column4</t></is></c>
<c r=\"F1\" t=\"inlineStr\"><is><t>column5</t></is></c>
<c r=\"G1\" t=\"inlineStr\"><is><t>column6</t></is></c>
<c r=\"H1\" t=\"inlineStr\"><is><t>column7</t></is></c>
<c r=\"I1\" t=\"inlineStr\"><is><t>column8</t></is></c>
<c r=\"J1\" t=\"inlineStr\"><is><t>column9</t></is></c>
<c r=\"K1\" t=\"inlineStr\"><is><t>column10</t></is></c>
......
</sheetData>
<pageMargins bottom=\"0.75\" footer=\"0.3\" header=\"0.3\" left=\"0.7\" right=\"0.7\" top=\"0.75\"/>
</worksheet>

以上就是一个xlsx文件里包含的xml文件,使用IO流将相关的信息写入到xml文件中去,最后压缩成xlsx文件,就可以得到一个xlsx格式的excel文件了。
源码
但是其中有个点需要注意,压缩方法不能使用java.util.zip里的,用java.util.zip得到的压缩文件打开会提示文件损坏,得换成apache的compress方法,因为这是poi相关包源码用到的压缩方法。至于为什么用java.util.zip生成的文件打不开,这个原因暂时未知。

下面是用写xml文件生成xlsx文件的代码demo。

package exceltest;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.function.Supplier;

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
import org.apache.commons.compress.utils.IOUtils;

/**
 * 借助xml文件生成xlsx文件
 * @author 程序员小川
 * @date 2021-12-21
 *
 */
public class XML2XlsxFileDemo {

	public static void main(String[] args) {
		testM();

		try {
			File file = new File("F:\\test996.xlsx");
			FileOutputStream outputStreamExcel = new FileOutputStream(file);
			ZipArchiveOutputStream zos = new ZipArchiveOutputStream(outputStreamExcel);
			compressDirectoryToZipfile("F:\\xlsxtest222", "F:\\xlsxtest222", zos);
			zos.flush();
			zos.finish();
			zos.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private static void compressDirectoryToZipfile(String rootDir, String sourceDir, ZipArchiveOutputStream out) throws IOException {
	    try {
	    	File[] files = new File(sourceDir).listFiles();
		    assert files != null;
		    for (File file : files) {
		        if (file.isDirectory()) {
		            compressDirectoryToZipfile(rootDir, sourceDir + File.separator + file.getName(), out);
		        } else {
		            ZipArchiveEntry entry = new ZipArchiveEntry(file.getAbsolutePath().substring(rootDir.length() + 1));
		            out.putArchiveEntry(entry);
		            try (InputStream in = new BufferedInputStream(new FileInputStream(sourceDir + File.separator + file.getName()))) {
		            	IOUtils.copy(in, out);
		            }
		            out.closeArchiveEntry();
		        }
		    }
	    } catch(Exception e) {
	    	e.printStackTrace();
	    }
	}
	
	public static void testM() {
		String filefolder = "F:\\xlsxtest222";
		try {
			File fo = new File(filefolder + File.separator + "_rels");
			if (!fo.exists()) {
				fo.mkdirs();
			}
			fo = new File(filefolder + File.separator + "docProps");
			if (!fo.exists()) {
				fo.mkdirs();
			}
			fo = new File(filefolder + File.separator + "xl" + File.separator + "_rels");
			if (!fo.exists()) {
				fo.mkdirs();
			}
			fo = new File(filefolder + File.separator + "xl" + File.separator + "worksheets");
			if (!fo.exists()) {
				fo.mkdirs();
			}
			
			File _rels_f = new File(filefolder + File.separator + "_rels" + File.separator + ".rels");
			if (!_rels_f.exists()) {
				_rels_f.createNewFile();
			}
			DataOutputStream rafs = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(_rels_f)));
			StringBuilder sb = new StringBuilder();
			sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
			sb.append("<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">\n");
			sb.append("<Relationship Id=\"rId1\" Target=\"xl/workbook.xml\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument\"/>\n");
			sb.append("<Relationship Id=\"rId2\" Target=\"docProps/app.xml\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties\"/>\n");
			sb.append("<Relationship Id=\"rId3\" Target=\"docProps/core.xml\" Type=\"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties\"/>\n");
			sb.append("</Relationships>");
			rafs.write(sb.toString().getBytes());
			rafs.flush();
			rafs.close();
			
			File docProps_appxml_f = new File(filefolder + File.separator + "docProps" + File.separator + "app.xml");
			if (!docProps_appxml_f.exists()) {
				docProps_appxml_f.createNewFile();
			}
			rafs = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(docProps_appxml_f)));
			sb = new StringBuilder();
			sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
			sb.append("<Properties xmlns=\"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties\"><Application>Apache POI</Application></Properties>\n");
			rafs.write(sb.toString().getBytes());
			rafs.flush();
			rafs.close();
			
			File docProps_corexml_f = new File(filefolder + File.separator + "docProps" + File.separator + "core.xml");
			if (!docProps_corexml_f.exists()) {
				docProps_corexml_f.createNewFile();
			}
			rafs = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(docProps_corexml_f)));
			sb = new StringBuilder();
			sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
			sb.append("<cp:coreProperties xmlns:cp=\"http://schemas.openxmlformats.org/package/2006/metadata/core-properties\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n");
			//格式化创建时间
			SimpleDateFormat datestr = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
			String date = datestr.format(new Date());
			sb.append("<dcterms:created xsi:type=\"dcterms:W3CDTF\">").append(date).append("</dcterms:created>\n");
			sb.append("<dc:creator>Apache POI</dc:creator>\n");
			sb.append("</cp:coreProperties>");
			rafs.write(sb.toString().getBytes());
			rafs.flush();
			rafs.close();
			
			File xl_sharedStrings_f = new File(filefolder + File.separator + "xl" + File.separator + "sharedStrings.xml");
			if (!xl_sharedStrings_f.exists()) {
				xl_sharedStrings_f.createNewFile();
			}
			rafs = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(xl_sharedStrings_f)));
			sb = new StringBuilder();
			sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
			sb.append("<sst count=\"0\" uniqueCount=\"0\" xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\"/>");
			rafs.write(sb.toString().getBytes());
			rafs.flush();
			rafs.close();
			
			File xl_styles_f = new File(filefolder + File.separator + "xl" + File.separator + "styles.xml");
			if (!xl_styles_f.exists()) {
				xl_styles_f.createNewFile();
			}
			rafs = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(xl_styles_f)));
			sb = new StringBuilder();
			sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
			sb.append("<styleSheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\"><numFmts count=\"0\"/><fonts count=\"1\"><font><sz val=\"11.0\"/><color indexed=\"8\"/><name val=\"Calibri\"/><family val=\"2\"/><scheme val=\"minor\"/></font></fonts><fills count=\"2\"><fill><patternFill patternType=\"none\"/></fill><fill><patternFill patternType=\"darkGray\"/></fill></fills><borders count=\"1\"><border><left/><right/><top/><bottom/><diagonal/></border></borders><cellStyleXfs count=\"1\"><xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\"/></cellStyleXfs><cellXfs count=\"1\"><xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\" xfId=\"0\"/></cellXfs></styleSheet>");
			rafs.write(sb.toString().getBytes());
			rafs.flush();
			rafs.close();
			
			File xl_workbook_f = new File(filefolder + File.separator + "xl" + File.separator + "workbook.xml");
			if (!xl_workbook_f.exists()) {
				xl_workbook_f.createNewFile();
			}
			rafs = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(xl_workbook_f)));
			sb = new StringBuilder();
			sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
			sb.append("<workbook xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\">\n");
			sb.append("<workbookPr date1904=\"false\"/>\n");
			sb.append("<bookViews>\n");
			sb.append("<workbookView activeTab=\"0\"/>\n");
			sb.append("</bookViews>\n");
			sb.append("<sheets>\n");
			for (int i=0; i<10;i++) {
				sb.append("<sheet name=\"第").append(i).append("页\" r:id=\"rId").append(i+3).append("\" sheetId=\"").append(i+1).append("\"/>\n");
			}
			sb.append("</sheets>\n");
			sb.append("</workbook>\n");
			rafs.write(sb.toString().getBytes());
			rafs.flush();
			rafs.close();
			
			
			ExecutorService completableFutureExecutor = Executors.newCachedThreadPool();
			List<CompletableFuture<String>> futures = new ArrayList<>();
	        for (int i = 0; i < 10; i++) {
	        	final int fi = i;
	        	CompletableFuture<String> completableFuture = CompletableFuture.supplyAsync(new Supplier<String>() {
	    			@Override
	    			public String get() {
	    				try {
	    					return createNewSheet(fi);
	    				} catch (Exception e) {
	    					e.printStackTrace();
	    					return null;
	    				}
	    			}
	    		}, completableFutureExecutor);
	        	
	            futures.add(completableFuture);
	        }
	        //等待全部完成
	        CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
	        
	        File xl__rels_workbookxml_f = new File(filefolder + File.separator + "xl" + File.separator +"_rels"+ File.separator + "workbook.xml.rels");
			if (!xl__rels_workbookxml_f.exists()) {
				xl__rels_workbookxml_f.createNewFile();
			}
			rafs = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(xl__rels_workbookxml_f)));
			sb = new StringBuilder();
			sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
			sb.append("<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">\n"); 
			sb.append("<Relationship Id=\"rId1\" Target=\"sharedStrings.xml\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings\"/>\n"); 
			sb.append("<Relationship Id=\"rId2\" Target=\"styles.xml\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles\"/>\n");
			for (int j = 0; j < futures.size(); j++) {
				String val = futures.get(j).get();
				sb.append("<Relationship Id=\"rId").append(j+3).append("\" Target=\"worksheets/").append(val).append("\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet\"/>\n");
			}
			sb.append("</Relationships>");
			rafs.write(sb.toString().getBytes());
			rafs.flush();
			rafs.close();
			
			
			File Content_Types_f = new File(filefolder + File.separator + "[Content_Types].xml");
			if (!Content_Types_f.exists()) {
				Content_Types_f.createNewFile();
			}
			rafs = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(Content_Types_f)));
			sb = new StringBuilder();
			sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
			sb.append("<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">\n"); 
			sb.append("<Default ContentType=\"application/vnd.openxmlformats-package.relationships+xml\" Extension=\"rels\"/>\n");
			sb.append("<Default ContentType=\"application/xml\" Extension=\"xml\"/>\n"); 
			sb.append("<Override ContentType=\"application/vnd.openxmlformats-officedocument.extended-properties+xml\" PartName=\"/docProps/app.xml\"/>\n"); 
			sb.append("<Override ContentType=\"application/vnd.openxmlformats-package.core-properties+xml\" PartName=\"/docProps/core.xml\"/>\n");
			sb.append("<Override ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml\" PartName=\"/xl/sharedStrings.xml\"/>\n"); 
			sb.append("<Override ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml\" PartName=\"/xl/styles.xml\"/>\n"); 
			sb.append("<Override ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml\" PartName=\"/xl/workbook.xml\"/>\n");
			for (int j = 0; j < futures.size(); j++) {
				String val = futures.get(j).get();
				sb.append("<Override ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml\" PartName=\"/xl/worksheets/").append(val).append("\"/>\n");
			}
			sb.append("</Types>");
			rafs.write(sb.toString().getBytes());
			rafs.flush();
			rafs.close();
			
			completableFutureExecutor.shutdown();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static String createNewSheet(int i) {
		String filename = "sheet" + (i+1) + ".xml";
		try {
			String filefolder = "F:\\xlsxtest222";
			File _rels_f = new File(filefolder + File.separator + "xl" + File.separator + "worksheets" + File.separator + filename);
			if (!_rels_f.exists()) {
				_rels_f.createNewFile();
			}
			DataOutputStream rafs = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(_rels_f)));
			StringBuilder sb = new StringBuilder();
			sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
			if (i == 0) {
				sb.append("<worksheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\"><dimension ref=\"A1\"/><sheetViews><sheetView workbookViewId=\"0\" tabSelected=\"true\"/></sheetViews><sheetFormatPr defaultRowHeight=\"15.0\"/><sheetData>\n");
			} else {
				sb.append("<worksheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\"><dimension ref=\"A1\"/><sheetViews><sheetView workbookViewId=\"0\"/></sheetViews><sheetFormatPr defaultRowHeight=\"15.0\"/><sheetData>\n");
			}
			for (int j = 0; j < 100; j++) {
				if (j == 0) {
					sb.append("<row r=\"").append(j+1).append("\">\n");
					sb.append("<c r=\"A1\" t=\"inlineStr\"><is><t>column0</t></is></c>");
					sb.append("<c r=\"B1\" t=\"inlineStr\"><is><t>column1</t></is></c>");
					sb.append("<c r=\"C1\" t=\"inlineStr\"><is><t>column2</t></is></c>");
					sb.append("<c r=\"D1\" t=\"inlineStr\"><is><t>column3</t></is></c>");
					sb.append("<c r=\"E1\" t=\"inlineStr\"><is><t>column4</t></is></c>");
					sb.append("<c r=\"F1\" t=\"inlineStr\"><is><t>column5</t></is></c>");
					sb.append("<c r=\"G1\" t=\"inlineStr\"><is><t>column6</t></is></c>");
					sb.append("<c r=\"H1\" t=\"inlineStr\"><is><t>column7</t></is></c>");
					sb.append("<c r=\"I1\" t=\"inlineStr\"><is><t>column8</t></is></c>");
					sb.append("<c r=\"J1\" t=\"inlineStr\"><is><t>column9</t></is></c>");
					sb.append("<c r=\"K1\" t=\"inlineStr\"><is><t>column10</t></is></c>");
					sb.append("</row>\n");
				} else {
					sb.append("<row r=\"").append(j+1).append("\">\n");
					sb.append("<c r=\"A").append(j+1).append("\" t=\"inlineStr\"><is><t>").append(j).append("</t></is></c>");
					sb.append("<c r=\"B").append(j+1).append("\" t=\"inlineStr\"><is><t>").append(String.valueOf(Math.random())).append("</t></is></c>");
					sb.append("<c r=\"C").append(j+1).append("\" t=\"inlineStr\"><is><t>").append(String.valueOf(Math.random())).append("</t></is></c>");
					sb.append("<c r=\"D").append(j+1).append("\" t=\"inlineStr\"><is><t>").append(String.valueOf(Math.random())).append("</t></is></c>");
					sb.append("<c r=\"E").append(j+1).append("\" t=\"inlineStr\"><is><t>").append(String.valueOf(Math.random())).append("</t></is></c>");
					sb.append("<c r=\"F").append(j+1).append("\" t=\"inlineStr\"><is><t>").append(String.valueOf(Math.random())).append("</t></is></c>");
					sb.append("<c r=\"G").append(j+1).append("\" t=\"inlineStr\"><is><t>").append(String.valueOf(Math.random())).append("</t></is></c>");
					sb.append("<c r=\"H").append(j+1).append("\" t=\"inlineStr\"><is><t>").append(String.valueOf(Math.random())).append("</t></is></c>");
					sb.append("<c r=\"I").append(j+1).append("\" t=\"inlineStr\"><is><t>").append(String.valueOf(Math.random())).append("</t></is></c>");
					sb.append("<c r=\"J").append(j+1).append("\" t=\"inlineStr\"><is><t>").append(String.valueOf(Math.random())).append("</t></is></c>");
					sb.append("<c r=\"K").append(j+1).append("\" t=\"inlineStr\"><is><t>").append(String.valueOf(Math.random())).append("</t></is></c>");
					sb.append("</row>\n");
				}
			}
			sb.append("</sheetData><pageMargins bottom=\"0.75\" footer=\"0.3\" header=\"0.3\" left=\"0.7\" right=\"0.7\" top=\"0.75\"/></worksheet>");
			rafs.write(sb.toString().getBytes());
			rafs.flush();
			rafs.close();
			return filename;
		} catch(Exception e) {
			e.printStackTrace();
			return null;
		}
	}
	
}

需要使用的依赖包commons-compressmaven坐标如下:

<dependency>
  <groupId>org.apache.commons</groupId>
  <artifactId>commons-compress</artifactId>
  <version>1.20</version>
</dependency>

以上就是全部内容,转载请注明出处。

Central Finance 全景解析:用 SAP S/4HANA 构建跨系统的财务中台与渐进式转型路径 Central Finance 是基于 SAP S/4HANA 的一种部署与应用场景:在不打断现有异构源系统运营的前提下,把多套 SAP 与非 SAP 系统中的财务与管理会计数据实时/准实时复制到一套中心化的 SAP S/4HANA 中,作为统一的记账与分析底座,逐步把选定的财务流程(如预算控制、付款、固定资产结账等)迁入中心系统。这让企业既能快速获得统一报表与统一核算结构,又为未来的整体迁移留出了弹性路径。 阅读详情

相关推荐

恶意代码实验3:Word宏病毒实验

只要下次打开这个word文档,就会执行以上代码,并将自身复制到Normal.dot(word文档的公共模板)和当前文档的ThisDocument中,同时改变函数名(模板中为Document_Close,当前文档为Document_Open),此时所有的word文档打开和关闭时,都将运行以上的病毒代码,可以加入适当的恶意代码,影响word的正常使用,本例中只是简单的跳出一个提示框。回答不正确三次,即可自动跳出病毒程序,但那时已经出现几十个文档。1、打开的宏编辑器如图所示,即可编写病毒代码。

qq_63949327的博客 6520

使用POI导出Excel出现The part /docProps/core.xml failed to be saved in the stream XXX异常

使用POI导出Excel出现The part /docProps/core.xml failed to be saved in the stream XXX异常

有术无道止于术,有道无术尚有可为。 7438

SAP IDOC EDI实战:跨公司采购订单自动转销售订单全流程解析

在企业系统集成中,不同业务系统间的数据交换往往依赖人工转录,不仅效率低下且容易出错。IDOC是SAP系统中最典型的数据交换载体,EDI则定义了标准化的报文传输规范,二者结合能够实现跨公司代码的业务单据自动化流转。基于SAP标准功能,通过输出控制触发、出站IDOC生成、端口与合作伙伴参数配置,以及入站功能模块对IDOC的解析,采购订单无需人工干预即可自动创建销售订单。这一机制具备异步解耦、状态可追踪、失败可重试等核心特性,适用于集团内部公司间采购转销售、多系统集成以及供应链上下游协同场景。文章从基础概念讲起,

weixin_42528780的博客 325

The part /docProps/core.xml fail to be saved

前端需要导出数据到excel 文件下载,但是后端只要数据超过一定数量就会报这个错,后面发现并不是后端的错 ,而是数据太多 需要处理,时间超过30秒,前端执行时候设置axios只有30秒延迟,断开连接。前端设置成100秒就好了,当然可能对其他连接也有影响,请自行调整 ...

oTianKongLan123的博客 4027

SpringDoc 基本使用指南

SpringDoc 凭借零配置启动注解简洁和深度兼容 Spring 生态的优势,已成为 Spring Boot API 文档的首选工具。自动化- 减少手动维护文档的成本;标准化- 严格遵循 OpenAPI 3 规范;可扩展- 分组、安全控制灵活适配复杂项目。访问即可查看交互式文档(默认路径)

墨鸦的博客 1万+

标准恢复二极管整流器的全球与中国市场2022-2028年:技术、参与者、趋势、市场规模及占有率研究报告

报告页数: 150 图表数: 100 报告价格:¥16800 本文研究全球与中国市场标准恢复二极管整流器的发展现状及未来发展趋势,分别从生产和消费的角度分析标准恢复二极管整流器的主要生产地区、主要消费地区以及主要的生产商。重点分析全球与中国市场的主要厂商产品特点、产品规格、不同规格产品的价格、产量、产值及全球和中国市场主要生产商的市场份额。 主要生产商包括: Yangzhou Yangjie Vishay Intertechnology Power Semiconductors Inc Nexperia B

Fj69258的博客 5860

生成Excel报错 The part /docProps/core.xml failed to be saved in the stream with marshaller

经过测试,单个Sheet在8300行左右或者以上就会报错,目前没有找到原因。解决: 单个Sheet保持5000行(或者根据实际情况处理),内容分成多个Sheet保存即可。

cpych的专栏 1万+

UE5 Metahuman与Blender手动绑定:ARKit面部动画实战对比

面部动画是角色动画领域的核心技术,其核心原理在于通过驱动面部骨骼或混合形状来模拟真实肌肉运动,从而赋予数字角色生命力。这项技术的价值在于极大地提升了虚拟角色的表现力与沉浸感,广泛应用于游戏开发、影视制作、虚拟现实和实时交互应用。在技术实现路径上,开发者常面临工业化集成方案与高度自定义方案的选择。本文聚焦于使用行业标准的ARKit 52个面部混合形状数据,深度对比了虚幻引擎Metahuman的工业化流程与Blender手动绑定方案在视觉保真度、工作流效率、性能开销和扩展性上的差异,为不同项目规模与技术需求的团

weixin_33901926的博客 452

POI事件模式指北(二)-Excel2007

POI事件模式指北(二)-Excel2007 1、简介 Excel2007(.xlsx)是现在最常用的Excel格式,对这种文件的读取也是非常常见的需求;同样的POI也提供用户模式(User API) 和事件模式(Event API) 两种方式供大家使用。 POI的事件模式占用内存更小,它利用基础的XML数据进行处理,适用于愿意学习.xlsx文件结构...

weixin_33722405的博客 378

机器学习入门基础 | 基于python的高光谱图像特征挖掘:PCA + 形态学属性处理可视化实战

本文介绍了一种基于PCA和形态学操作的高光谱图像特征提取方法。通过主成分分析降低数据维度,再运用面积开闭操作增强空间结构特征,有效去除噪声并填补孔洞。实验采用WHU-HI-HanChuan数据集,提供完整的Python实现代码,包括数据加载、PCA降维、形态学处理及结果可视化等步骤。该方法能够显著改善图像质量,为后续分类和变化检测任务提供更好的特征输入。实验结果表明,不同阈值的形态学处理能呈现不同程度的空间结构增强效果,对区域生长、分割和聚类等应用具有重要价值。

lestatlu的博客 1052

深度排查:网讯网卡WX1860AL4千兆网口降速百兆的硬件陷阱

本文详细剖析了网讯网卡WX1860AL4千兆网口降速至百兆的硬件故障排查过程。通过分析千兆以太网硬件原理,提供从网线、供电到PCB走线、焊接残留的标准化检修流程,并分享两种典型硬件陷阱(线序错误与焊锡短路)的实战修复案例,为硬件工程师解决类似传输速率问题提供系统性的诊断思路与方法。

a3b4c5的博客 1121

读取微软三剑客的内容创建信息

在微软办公套件生成的文件里面(xlsx,docx,pptx文件),存放了文档内容的创建和修改信息(不同于文件创建和修改信息),包括内容创建者、创建时间、最后一次修改的时间和修改人。这些信息可以用文件管理器,右键-详细信息页面能查看到: 那么,我们怎么把这些信息读出来呢? 原理: 2007版以上的三剑客文件,实际上是压缩后的XML文件,这些信息保存在docProps/core.x...

anger2061的博客 412

【ARM Trace32(劳特巴赫) 使用介绍 13 -- Trace32 Var 变量篇】

例如我们已经知道一个符号(可能是变量或者函数)的地址,怎么确定这个地址是一个变量还是一个函数呢?如果是变量的话,变量名是啥?变量定义的位置在哪?如果是函数,函数名是啥?函数定义的位置又在哪呢?查看结构体变量 str_t32 的值。例如我们已经知道了一个符号的地址为。在map文件中的地址为。

CodingCos的博客 2359

Excel大批量数据的导入和导出,如何做优化?

作者:Albenhttps://albenw.github.io/posts/d093ca4e概要 Java对Excel的操作一般都是用POI,但是数据量大的话可能会导致频繁的FGC或O...

Java知音 3496

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

Excel 大批量数据的导入和导出,如何做优化?

点击上方“芋道源码”,选择“设为星标”管她前浪,还是后浪?能浪的浪,才是好浪!每天 8:55 更新文章,每天掉亿点点头发...源码精品专栏原创 | Java 2020 超神之路,很肝~...

芋艿V 313

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

excel清空sheet内容 poi_Excel大批量数据的导入和导出,如何做优化?

概要Java对Excel的操作一般都是用POI,但是数据量大的话可能会导致频繁的FGC或OOM,这篇文章跟大家说下如果避免踩POI的坑,以及分别对于xls和xlsx文件怎么优化大批量数据的导入和导出。一次线上问题这是一次线上的问题,因为一个大数据量的Excel导出功能,而导致服务器频繁FGC,具体如图所示可以看出POI的对象以及相关的XML对象占用了绝大部分的内存消耗,频繁FGC说明这些对象一直存...

weixin_39680380的博客 629

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

这套 Excel 大批量导入导出解决方案,太牛逼了

概要 Java对Excel的操作一般都是用POI,但是数据量大的话可能会导致频繁的FGC或OOM,这篇文章跟大家说下如果避免踩POI的坑,以及分别对于xls和xlsx文件怎么优化大批量数据的导入和导出。 一次线上问题 这是一次线上的问题,因为一个大数据量的Excel导出功能,而导致服务器频繁FGC,具体如图所示 可以看出POI的对象以及相关的XML对象占用了绝大部分的内存消耗,频繁FGC说明这些对象一直存活,没有被回收。 原因是由于导出的数据比较大量,大概有10w行 * 50列,由于

Java面试官-凌霄 2033

bootstraptable 怎么在特定行添加数据_小胖:远哥,几万行数据导出超时了怎么办?...

点击上方一个优秀的废人,选择设为星标优质文章,及时送达巨人的肩膀:albenw.github.io/posts/d093ca4e概要Java 对 Excel 的操作一般都是用 POI,但是数据量大的话可能会导致频繁的 FGC 或 OOM,这篇文章跟大家说下如果避免踩 POI 的坑,以及分别对于 xls 和 xlsx 文件怎么优化大批量数据的导入和导出。一次线上问题这是一次线上的问题,...

weixin_34567079的博客 211
上一篇: LeetCode.1217-交换芯片(Play with Chips)
下一篇: 使用TableGeneration生成表格数据集
程序员小川
博客等级 码龄10年 47粉丝 305原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址