Advanced Options - Inspiredsoft/exporter GitHub Wiki

#Excluded Properties

In the section Basic Example we saw how to exclude a property in a model using the annotation @Unexportable. Another way to export a subset of the properties is to define such a set in the annotation @ExpoElement at class level:

@ExpoElement( property = { 
            @ExpoProperty( value = "name" ), 
            @ExpoProperty( value = "surname" ),
            @ExpoProperty( value = "login" )} )
public class User {
    ...
}

Moreover, if there is a recurrent property in every model (e.g. the id) it is possible to redefine the method getExcludedProperties of the Exporter class in that way:

private TextExporter txtexporter = new TextExporter(){
    protected List<String> getExcludedProperties() {
        return Arrays.asList( new String[]{ "id, "password", ...} );
    };
};

#Header Customization In the section Basic Example the header of the exported file was generate based on the property name. In particular every column ha the capitalized property name as header. E.g. the property "login" in the User class generates a column with header name Login. More in general the property name is capitalized adding a space on every word composing the name, e.g a property fullUserName will generate the header Full User Name.

To change this behavior can be redefined the method getText of the Exporter class:

private TextExporter txtexporter = new TextExporter(){
    protected String getText(String key)  {
        return ...;
    };
};

where the parameter key is define annotating the get method of the property with the annotation @ExpoProperty:

@ExpoProperty( labelKey="label.user.name" )

#Column Order To change the order in witch the properties are exported just set the property position in the @ExpoProperty annotation, where 1 is the first position.

@ExpoProperty( position = 1 )

#Data Transformation Suppose we have a situation where a property is used to store an information from a set of finite values. E.g. a char to represent the gender: male or female, an integer to represent a type of car: economy, luxury, sport, family, and so on. In such situation we are not interested in exporting the row data, the character or the number, but its transformation. This can be done using the property prefixKey:

@ExpoProperty( prefixKey = "gender." )
public Char getGender(){...}

where in the the two label gender.M and gender.F should be returned from the method getText described in the section Header Customization.

⚠️ **GitHub.com Fallback** ⚠️