Changeset 7651
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/clients/web/net/sf/basedb/clients/web/plugins/SimpleExport.java
r7650 r7651 648 648 Type valueType = ep.annotationType.getValueType(); 649 649 UnitConverter unitConverter = null; 650 if (defaultUnit != null)651 {652 if (ep.unit != null) unitConverter = ep.unit.getUnitConverter(defaultUnit);653 if (ep.unit == null) unitSymbol = defaultUnit.getDisplaySymbol();654 }655 650 values = new ArrayList(); 656 651 for (AnnotationSnapshot s : list) 657 652 { 653 if (defaultUnit != null && ep.unit == null && unitConverter == null) // Units should be converted for each item 654 { 655 Unit u = s.getActualUnit(dc); 656 unitConverter = u.getUnitConverter(defaultUnit); 657 unitSymbol = u.getDisplaySymbol(); 658 } 658 659 values.addAll(s.getActualValues(unitConverter, valueType)); 659 660 } -
trunk/src/clients/web/net/sf/basedb/clients/web/plugins/XlsxTemplate.java
r7650 r7651 25 25 import java.io.OutputStream; 26 26 import java.util.Collection; 27 import java.util.Date;28 import java.util.HashMap;29 27 import java.util.List; 30 import java.util.Map;31 28 32 29 import org.apache.poi.ss.usermodel.Cell; 33 import org.apache.poi.ss.usermodel.CellStyle;34 import org.apache.poi.ss.usermodel.DataFormat;35 30 import org.apache.poi.ss.usermodel.Row; 36 31 import org.apache.poi.ss.usermodel.Sheet; … … 44 39 import net.sf.basedb.util.Values; 45 40 import net.sf.basedb.util.excel.CellStyleCreator; 46 import net.sf.basedb.util.excel.ExcelFormatter;47 41 import net.sf.basedb.util.excel.ExcelValue; 48 42 import net.sf.basedb.util.formatter.Formatter; … … 157 151 throws IOException 158 152 { 159 if (values != null && values.size() == 1) 153 if (values == null || values.size() == 0) 154 { 155 writeProperty(ep, null); 156 } 157 else if (values.size() == 1 && unit == null) 160 158 { 161 159 writeProperty(ep, values.get(0)); 162 return; 163 } 164 Cell cell = currentRow.createCell(colNum++); 165 Formatter f = ep.formatter; 166 if (unit != null) f = new PrefixSuffixFormatter("", f, PrefixSuffixFormatter.NBSP + unit); 167 cell.setCellValue(Values.getString(values, collectionSeparator, true, f)); 160 } 161 else 162 { 163 Cell cell = currentRow.createCell(colNum++); 164 Formatter f = ep.formatter; 165 if (unit != null) f = new PrefixSuffixFormatter("", f, PrefixSuffixFormatter.NBSP + unit); 166 ExcelValue ev = ExcelValue.asString(Values.getString(values, collectionSeparator, true, f)); 167 ev.writeTo(cell, styleCreator); 168 } 168 169 } 169 170 … … 172 173 */ 173 174 @Override 174 @SuppressWarnings( "unchecked")175 @SuppressWarnings({ "unchecked", "rawtypes" }) 175 176 public void writeProperty(ExportedProperty ep, Object data) 176 177 throws IOException … … 186 187 */ 187 188 @Override 188 @SuppressWarnings( "unchecked")189 @SuppressWarnings({ "unchecked", "rawtypes" }) 189 190 public void writeCollection(ExportedProperty ep, Collection<?> values) 190 191 throws IOException 191 192 { 192 Cell cell = currentRow.createCell(colNum++); 193 cell.setCellValue(Values.getString(values, collectionSeparator, true, ep.formatter)); 193 if (values == null || values.size() == 0) 194 { 195 writeProperty(ep, null); 196 } 197 else if (values.size() == 1) 198 { 199 writeProperty(ep, values.iterator().next()); 200 } 201 else 202 { 203 Cell cell = currentRow.createCell(colNum++); 204 ExcelValue ev = ExcelValue.asString(Values.getString(values, collectionSeparator, true, ep.formatter)); 205 ev.writeTo(cell, styleCreator); 206 } 194 207 } 195 208 -
trunk/src/core/net/sf/basedb/util/excel/ExcelValue.java
r7649 r7651 129 129 protected final String format; 130 130 131 ExcelValue(T value, String format)131 protected ExcelValue(T value, String format) 132 132 { 133 133 this.value = value;
Note: See TracChangeset
for help on using the changeset viewer.