Class CSVDataExporter
- java.lang.Object
-
- com.googlecode.wicket.kendo.ui.datatable.export.CSVDataExporter
-
- All Implemented Interfaces:
IDataExporter
,Serializable
,org.apache.wicket.util.io.IClusterable
public class CSVDataExporter extends Object implements IDataExporter
Provides export capability for theDataTable
- Author:
- Sebastien Briquet - sebfz1
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CSVDataExporter.DataExporterResourceStreamWriter
Provides theIResourceStreamWriter
for theCSVDataExporter
-
Constructor Summary
Constructors Constructor Description CSVDataExporter()
ConstructorCSVDataExporter(String contentType)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
export(DataTable<?> table, String filename)
static void
export(org.apache.wicket.request.cycle.RequestCycle cycle, DataTable<?> table, String filename)
ExportsDataTable
data to a CSV filestatic void
export(org.apache.wicket.request.cycle.RequestCycle cycle, org.apache.wicket.markup.repeater.data.IDataProvider<?> provider, List<IExportableColumn> columns, String filename)
ExportsDataTable
data to a CSV file<T> void
exportData(org.apache.wicket.markup.repeater.data.IDataProvider<T> provider, List<IExportableColumn> columns, OutputStream output)
Exports all data provided by theIDataProvider
to theOutputStream
.<T> void
exportData(org.apache.wicket.markup.repeater.data.IDataProvider<T> provider, List<IExportableColumn> columns, OutputStream output, long first, long count)
Exports the data provided by theIDataProvider
to theOutputStream
.String
getContentType()
Gets the content typeboolean
isExportHeadersEnabled()
Indicates whether headers will be written to the outputstatic org.apache.wicket.extensions.ajax.AjaxDownloadBehavior
newAjaxDownloadBehavior(DataTable<?> table, String filename)
Gets a newAjaxDownloadBehavior
that allows to exportDataTable
data to a CSV filestatic org.apache.wicket.extensions.ajax.AjaxDownloadBehavior
newAjaxDownloadBehavior(org.apache.wicket.markup.repeater.data.IDataProvider<?> provider, List<IExportableColumn> columns, String filename)
Gets a newAjaxDownloadBehavior
that allows to exportDataTable
data to a CSV fileprotected String
quoteValue(String value)
Quotes a value for export to CSV.
According to RFC4180, this should just duplicate all occurrences of the quote character and wrap the result in the quote character.
-
-
-
Constructor Detail
-
CSVDataExporter
public CSVDataExporter()
Constructor
-
CSVDataExporter
public CSVDataExporter(String contentType)
Constructor- Parameters:
contentType
- the content-type, ie: text/csv
-
-
Method Detail
-
getContentType
public String getContentType()
Gets the content type- Specified by:
getContentType
in interfaceIDataExporter
- Returns:
- the content type
-
isExportHeadersEnabled
public boolean isExportHeadersEnabled()
Indicates whether headers will be written to the output- Specified by:
isExportHeadersEnabled
in interfaceIDataExporter
- Returns:
- true or false
-
quoteValue
protected String quoteValue(String value)
Quotes a value for export to CSV.
According to RFC4180, this should just duplicate all occurrences of the quote character and wrap the result in the quote character.- Parameters:
value
- The value to be quoted.- Returns:
- a quoted copy of the value.
-
exportData
public <T> void exportData(org.apache.wicket.markup.repeater.data.IDataProvider<T> provider, List<IExportableColumn> columns, OutputStream output) throws IOException
Exports all data provided by theIDataProvider
to theOutputStream
.- Specified by:
exportData
in interfaceIDataExporter
- Type Parameters:
T
- the object type- Parameters:
provider
- theIDataProvider
columns
- the list ofIColumn
output
- theOutputStream
- Throws:
IOException
- if this could not write the file out
-
exportData
public <T> void exportData(org.apache.wicket.markup.repeater.data.IDataProvider<T> provider, List<IExportableColumn> columns, OutputStream output, long first, long count) throws IOException
Exports the data provided by theIDataProvider
to theOutputStream
.- Type Parameters:
T
- the object type- Parameters:
provider
- theIDataProvider
columns
- the list ofIColumn
output
- theOutputStream
first
- the first row of datacountcount
- the number of elements to retrieve- Throws:
IOException
- if this could not write the file out
-
export
public static void export(org.apache.wicket.request.cycle.RequestCycle cycle, DataTable<?> table, String filename)
ExportsDataTable
data to a CSV file- Parameters:
cycle
- theRequestCycle
table
- theDataTable
filename
- the file name of the output
-
export
public static void export(org.apache.wicket.request.cycle.RequestCycle cycle, org.apache.wicket.markup.repeater.data.IDataProvider<?> provider, List<IExportableColumn> columns, String filename)
ExportsDataTable
data to a CSV file- Parameters:
cycle
- theRequestCycle
provider
- theIDataProvider
columns
- the list ofIExportableColumn
filename
- the file name of the output
-
newAjaxDownloadBehavior
public static org.apache.wicket.extensions.ajax.AjaxDownloadBehavior newAjaxDownloadBehavior(DataTable<?> table, String filename)
Gets a newAjaxDownloadBehavior
that allows to exportDataTable
data to a CSV file- Parameters:
table
- theDataTable
filename
- the file name of the output- Returns:
- a new
AjaxDownloadBehavior
-
newAjaxDownloadBehavior
public static org.apache.wicket.extensions.ajax.AjaxDownloadBehavior newAjaxDownloadBehavior(org.apache.wicket.markup.repeater.data.IDataProvider<?> provider, List<IExportableColumn> columns, String filename)
Gets a newAjaxDownloadBehavior
that allows to exportDataTable
data to a CSV file- Parameters:
provider
- theIDataProvider
columns
- the list ofIExportableColumn
filename
- the file name of the output- Returns:
- a new
AjaxDownloadBehavior
-
-