Skip to content

Commit ebfe545

Browse files
committed
Added xls/xlsx resize
1 parent af52b76 commit ebfe545

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<groupId>org.fugerit.java</groupId>
66
<artifactId>query-export-tool</artifactId>
77

8-
<version>0.3.0</version>
8+
<version>0.3.1</version>
99
<packaging>jar</packaging>
1010

1111
<name>query-export-tool</name>
@@ -23,8 +23,8 @@
2323
<maven.compiler.target>1.8</maven.compiler.target>
2424
<maven.compiler.source>1.8</maven.compiler.source>
2525
<!-- libraries versions -->
26-
<fj-version>0.7.4.8</fj-version>
27-
<opencsv-version>4.6</opencsv-version>
26+
<fj-version>0.7.6.8</fj-version>
27+
<opencsv-version>5.6</opencsv-version>
2828
<poi-version>4.1.2</poi-version>
2929
</properties>
3030

src/main/java/org/fugerit/java/query/export/facade/format/QueryExportHandlerXLSBase.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,33 @@
1818

1919
public abstract class QueryExportHandlerXLSBase extends QueryExportHandler {
2020

21+
public static void resizeSheet( Sheet s ) {
22+
Row row = s.getRow( 0 );
23+
Iterator<Cell> cells = row.cellIterator();
24+
while ( cells.hasNext() ) {
25+
Cell c = cells.next();
26+
s.autoSizeColumn( c.getColumnIndex() );
27+
}
28+
}
29+
30+
public static void autoSizeColumns(Workbook workbook) {
31+
int numberOfSheets = workbook.getNumberOfSheets();
32+
for (int i = 0; i < numberOfSheets; i++) {
33+
Sheet sheet = workbook.getSheetAt(i);
34+
resizeSheet( sheet );
35+
}
36+
}
37+
2138
public QueryExportHandlerXLSBase(String format) {
2239
super(format);
2340
}
2441

2542
public static final String ARG_XLS_TEMPLATE = "xls-template";
2643

44+
public static final String ARG_XLS_RESIZE = "xls-resize";
45+
46+
public static final String ARG_XLS_RESIZE_DEFAULT = "false";
47+
2748
private void addRow( Iterator<MetaField> record, Sheet sheet, int index ) throws Exception {
2849
int col = 0;
2950
Row row = sheet.createRow( index );

0 commit comments

Comments
 (0)