Changeset 7648


Ignore:
Timestamp:
Mar 13, 2019, 3:33:25 PM (3 years ago)
Author:
Nicklas Nordborg
Message:

References #2160: Table exporter should support exporting to Excel files

Added Excel support to well coordinates and string that are normally encoded for use with HTML that no longer need to be escaped for HTML-unsafe characters.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/web/net/sf/basedb/clients/web/formatter/NiceFormatter.java

    r6127 r7648  
    2323
    2424import net.sf.basedb.clients.web.util.HTML;
     25import net.sf.basedb.util.excel.ExcelFormatter;
     26import net.sf.basedb.util.excel.ExcelValue;
    2527import net.sf.basedb.util.formatter.Formatter;
    2628
     
    3537*/
    3638public class NiceFormatter
    37   implements Formatter<String>
     39  implements Formatter<String>, ExcelFormatter<String, String>
    3840{
    3941
     
    7678  // -------------------------------------------
    7779
     80  /**
     81    No escaping is needed.
     82    @since 3.15
     83  */
     84  @Override
     85  public ExcelValue<String> toExcelValue(String value)
     86  {
     87    return ExcelValue.asString(value);
     88  }
     89
    7890}
  • trunk/src/clients/web/net/sf/basedb/clients/web/formatter/StringFormatter.java

    r6127 r7648  
    2323
    2424import net.sf.basedb.clients.web.util.HTML;
     25import net.sf.basedb.util.excel.ExcelFormatter;
     26import net.sf.basedb.util.excel.ExcelValue;
    2527import net.sf.basedb.util.formatter.Formatter;
    2628
     
    3537*/
    3638public class StringFormatter
    37   implements Formatter<String>
     39  implements Formatter<String>, ExcelFormatter<String, String>
    3840{
    3941
     
    6062  // -------------------------------------------
    6163
     64  /**
     65    No escaping is needed.
     66    @since 3.15
     67  */
     68  @Override
     69  public ExcelValue<String> toExcelValue(String value)
     70  {
     71    return ExcelValue.asString(value);
     72  }
     73
    6274}
  • trunk/src/core/net/sf/basedb/util/formatter/WellCoordinateFormatter.java

    r6898 r7648  
    2323
    2424import net.sf.basedb.util.Coordinate;
     25import net.sf.basedb.util.excel.ExcelFormatter;
     26import net.sf.basedb.util.excel.ExcelValue;
    2527
    2628
     
    3638*/
    3739public class WellCoordinateFormatter
    38   implements Formatter<Integer>
     40  implements Formatter<Integer>, ExcelFormatter<Integer, Object>
    3941{
    4042  private boolean toAlpha;
     
    6769  }
    6870  // -------------------------------------------
     71
     72  @SuppressWarnings({ "rawtypes", "unchecked" })
     73  @Override
     74  public ExcelValue<Object> toExcelValue(Integer value)
     75  {
     76    if (value == null) return null;
     77    int v = value+1;
     78    ExcelValue ev = toAlpha ? ExcelValue.asString(Coordinate.numericToAlpha(v)) : ExcelValue.asInt(v);
     79    return ev;
     80  }
    6981 
    7082}
Note: See TracChangeset for help on using the changeset viewer.