Tag: spring batch

使用Apache POI将XLTM转换为XLSX时出错

我想将Excel XLTM文件转换为XLSX格式,作为Spring-Batch步骤的一部分。 我正在使用下面的代码来转换文件: def convertXltmToXlsx(String oldFilename, String newFileName) { OPCPackage pkg = OPCPackage.open(new FileInputStream(oldFilename)); pkg.replaceContentType( "application/vnd.ms-excel.template.macroEnabled.main+xml", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"); FileOutputStream out = new FileOutputStream(newFileName); pkg.save(out); out.close(); } 但是,当我尝试用Excel打开文件( converted.xlsx )时,我收到以下消息: The file 'converted.xlsx' is a macro-free file, but contains macro-enabled content. 当我修改代码来打印旧文件和新文件的内容types时,请执行以下操作: def parts = pkg.getParts() parts.each { part -> println "Part type: ${part.getContentType()}" } // do […]

使用spring批处理和apache poi写入来自多个源的数据

我目前有一个可用的Spring批处理应用程序,它使用ItemReader从Oracle数据库中读取SQL视图,并将该数据写入Excel文件。 但是,我想从多个视图中读取数据并写入同一个Excel文件 – 我该如何实现? 码: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:batch="http://www.springframework.org/schema/batch" xmlns:context="http://www.springframework.org/schema/context" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:c24="http://schema.c24.biz/spring-core" xmlns:bat-c24="http://schema.c24.biz/spring-batch" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation=" http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.1.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd http://schema.c24.biz/spring-core http://schema.c24.biz/spring-core.xsd http://schema.c24.biz/spring-batch http://schema.c24.biz/spring-batch.xsd"> <bean id="launchHelper" class="com.launcher.management.DummyPreJobHelper" /> <bean id="rowMapper" class="com.exporter.DynamicComplexDataObjectRowMapper"/> <bean id="itemReader" class="com.exporter.ViewJdbcCursorItemReader" scope="step"> <property name="dataSource" ref="dataSource" /> <property name="viewName" value="V_CARS" /> <property name="fetchSize" value="5000" /> […]