Skip to content

Commit 06947a9

Browse files
committed
write large Excel file support divided Sheets
1 parent 48dbeaf commit 06947a9

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

common/src/main/java/com/robin/core/fileaccess/iterator/XlsxFileIterator.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ protected void pullNext() throws Exception {
225225
streamReader.close();
226226
readStreams=sheetStreams.next();
227227
streamReader=factory.createXMLStreamReader(readStreams,colmeta.getEncode());
228+
if(hasHeader) {
229+
readNext();
230+
}
228231
}
229232
readNext();
230233
}

common/src/main/java/com/robin/core/fileaccess/writer/XlsxFileWriter.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,12 @@
4040
* Xlsx StaX writer,Support divided Sheet write,MAX_LINE max sheet lines
4141
*/
4242
public class XlsxFileWriter extends TextBasedFileWriter{
43-
private XMLOutputFactory factory;
4443
private XMLStreamWriter streamWriter;
4544
private XSSFWorkbook workbook;
4645
private OPCPackage opcPackage;
4746

4847
private static final char CHARA = 'A';
49-
private Map<String,CellStyle> cellStyleMap=new HashMap<>();
48+
private final Map<String,CellStyle> cellStyleMap=new HashMap<>();
5049
private int rowPos=2;
5150
private int currentSheetPos=0;
5251
private ExcelSheetProp sheetProp;
@@ -85,7 +84,7 @@ public XlsxFileWriter(DataCollectionMeta colmeta, AbstractFileSystemAccessor acc
8584
public void beginWrite() throws IOException {
8685
super.beginWrite();
8786
try {
88-
factory=XMLOutputFactory.newFactory();
87+
XMLOutputFactory factory=XMLOutputFactory.newFactory();
8988
workbook = new XSSFWorkbook();
9089
Field field = workbook.getClass().getSuperclass().getDeclaredField("pkg");
9190
field.setAccessible(true);

core/src/main/java/com/robin/core/base/dao/IjdbcDao.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public interface IjdbcDao {
200200
* @return
201201
* @throws DAOException
202202
*/
203-
<T extends BaseObject>T getEntity(Class<T> clazz, Serializable value) throws DAOException;
203+
<T extends BaseObject,P extends Serializable>T getEntity(Class<T> clazz, P value) throws DAOException;
204204

205205
/**
206206
* Execute Sql with Config query

core/src/main/java/com/robin/core/base/dao/JdbcDao.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ public <T extends BaseObject, P extends Serializable> int deleteByCondition(Clas
796796

797797

798798
@Override
799-
public <T extends BaseObject> T getEntity(Class<T> clazz, Serializable id) throws DAOException {
799+
public <T extends BaseObject,P extends Serializable> T getEntity(Class<T> clazz, P id) throws DAOException {
800800
try {
801801
T obj = clazz.getDeclaredConstructor().newInstance();
802802
EntityMappingUtil.SelectSegment segment = EntityMappingUtil.getSelectPkSegment(clazz, id, sqlGen, this);

0 commit comments

Comments
 (0)