= ExcelService
:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

== API

[source,java]
.ExcelService.java
----
interface ExcelService {
  String XSLX_MIME_TYPE;
  Blob toExcel(List<T> domainObjects, Class<T> cls, String sheetName, String fileName)     // <.>
  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)     // <.>
  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)
}
----

<.> xref:#toExcel_List_Class_String_String[toExcel(List, Class, String, String)]
+
--
Creates a Blob holding a spreadsheet of the domain objects.
--
<.> xref:#fromExcel_Blob_Class_String[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]
=== 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]
=== 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.
