-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from croz-ltd/feature_easierInitializationOfFl…
…atDataForExcelReport Feature easier initialisation of flat data for excel report
- Loading branch information
Showing
4 changed files
with
34 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 9 additions & 8 deletions
17
...h-excel/src/test/java/net/croz/nrich/excel/testutil/ExcelReportRequestGeneratingUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,30 @@ | ||
package net.croz.nrich.excel.testutil; | ||
|
||
import lombok.SneakyThrows; | ||
import net.croz.nrich.excel.api.model.MultiRowDataProvider; | ||
import net.croz.nrich.excel.api.request.CreateExcelReportRequest; | ||
|
||
import java.io.OutputStream; | ||
|
||
public final class ExcelReportRequestGeneratingUtil { | ||
|
||
private static final String TEMPLATE_PATH = "classpath:excel/template.xlsx"; | ||
|
||
private ExcelReportRequestGeneratingUtil() { | ||
} | ||
|
||
public static CreateExcelReportRequest createExcelReportRequest(Object[][] rowData, int batchSize, OutputStream outputStream, int firstRowIndex) { | ||
MultiRowDataProvider multiRowDataProvider = (start, limit) -> start == 0 ? rowData : null; | ||
|
||
return createExcelReportRequest(rowData == null ? null : multiRowDataProvider, batchSize, outputStream, firstRowIndex); | ||
return CreateExcelReportRequest.fromFlatData(rowData) | ||
.batchSize(batchSize) | ||
.outputStream(outputStream) | ||
.templatePath(TEMPLATE_PATH) | ||
.firstRowIndex(firstRowIndex).build(); | ||
} | ||
|
||
@SneakyThrows | ||
public static CreateExcelReportRequest createExcelReportRequest(MultiRowDataProvider multiRowDataProvider, int batchSize, OutputStream outputStream, int firstRowIndex) { | ||
return CreateExcelReportRequest.builder() | ||
.multiRowDataProvider(multiRowDataProvider) | ||
return CreateExcelReportRequest.fromRowDataProvider(multiRowDataProvider) | ||
.batchSize(batchSize) | ||
.outputStream(outputStream) | ||
.templatePath("classpath:excel/template.xlsx") | ||
.templatePath(TEMPLATE_PATH) | ||
.firstRowIndex(firstRowIndex).build(); | ||
} | ||
} |