ExcelService

Provides a set of utilities

API

ExcelService.java
interface ExcelService {
  String XSLX_MIME_TYPE;
  Blob toExcel(List<T> domainObjects, Class<T> cls, String sheetName, String fileName)     (1)
  Blob toExcel(List<T> domainObjects, Class<T> cls, String sheetName, String fileName, InputStream in)
  Blob toExcel(WorksheetContent worksheetContent, String fileName)
  Blob toExcel(WorksheetContent worksheetContent, String fileName, InputStream in)
  Blob toExcel(List<WorksheetContent> worksheetContents, String fileName)
  Blob toExcel(List<WorksheetContent> worksheetContents, String fileName, InputStream in)
  Blob toExcelPivot(List<T> domainObjects, Class<T> cls, String fileName)
  Blob toExcelPivot(List<T> domainObjects, Class<T> cls, String sheetName, String fileName)
  Blob toExcelPivot(WorksheetContent worksheetContent, String fileName)
  Blob toExcelPivot(List<WorksheetContent> worksheetContents, String fileName)
  List<T> fromExcel(Blob excelBlob, Class<T> cls, String sheetName)     (2)
  List<T> fromExcel(Blob excelBlob, Class<T> cls, String sheetName, Mode mode)
  List<T> fromExcel(Blob excelBlob, WorksheetSpec worksheetSpec)
  List<List<?>> fromExcel(Blob excelBlob, List<WorksheetSpec> worksheetSpecs)
  List<List<?>> fromExcel(Blob excelBlob, WorksheetSpec.Matcher matcher)
  List<List<?>> fromExcel(Blob excelBlob, WorksheetSpec.Matcher matcher, WorksheetSpec.Sequencer sequencer)
}
1 toExcel(List, Class, String, String)

Creates a Blob holding a spreadsheet of the domain objects.

2 fromExcel(Blob, Class, String)

Returns a list of objects for each line in the spreadsheet, of the specified type.

Members

toExcel(List, Class, String, String)

Creates a Blob holding a spreadsheet of the domain objects.

There are no specific restrictions on the domain objects; they can be either persistable entities or view models. Do be aware though that if imported back using #fromExcel(Blob, Class, String) , then new instances are always created. It is generally better therefore to work with view models than to work with entities. This also makes it easier to maintain backward compatibility in the future if the persistence model changes; using view models represents a stable API for import/export.

fromExcel(Blob, Class, String)

Returns a list of objects for each line in the spreadsheet, of the specified type.

If the class is a view model then the objects will be properly instantiated, with the correct view model memento); otherwise the objects will be simple transient objects.