Search in sources :

Example 1 with PasswordField

use of com.manydesigns.elements.fields.PasswordField in project Portofino by ManyDesigns.

the class XlsUtil method addFieldToCell.

public void addFieldToCell(WritableSheet sheet, int i, int j, Field field) throws WriteException {
    if (field instanceof NumericField) {
        NumericField numField = (NumericField) field;
        if (numField.getValue() != null) {
            jxl.write.Number number;
            BigDecimal decimalValue = numField.getValue();
            if (numField.getDecimalFormat() == null) {
                number = new Number(j, i, decimalValue.doubleValue());
            } else {
                number = new Number(j, i, decimalValue.doubleValue(), getNumberFormat(numField.getDecimalFormat().toPattern()));
            }
            sheet.addCell(number);
        }
    } else if (field instanceof PasswordField) {
        Label label = new Label(j, i, PasswordField.PASSWORD_PLACEHOLDER);
        sheet.addCell(label);
    } else if (field instanceof DateField) {
        DateField dateField = (DateField) field;
        DateTime dateCell;
        Date date = dateField.getValue();
        if (date != null) {
            dateCell = new DateTime(j, i, date, getDateFormat(dateField.getDatePattern()));
            sheet.addCell(dateCell);
        }
    } else {
        Label label = new Label(j, i, field.getStringValue());
        sheet.addCell(label);
    }
}
Also used : Number(jxl.write.Number) Number(jxl.write.Number) NumericField(com.manydesigns.elements.fields.NumericField) PasswordField(com.manydesigns.elements.fields.PasswordField) DateField(com.manydesigns.elements.fields.DateField) jxl.write(jxl.write) BigDecimal(java.math.BigDecimal) Date(java.util.Date)

Aggregations

DateField (com.manydesigns.elements.fields.DateField)1 NumericField (com.manydesigns.elements.fields.NumericField)1 PasswordField (com.manydesigns.elements.fields.PasswordField)1 BigDecimal (java.math.BigDecimal)1 Date (java.util.Date)1 jxl.write (jxl.write)1 Number (jxl.write.Number)1