<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                #### 2.7 如何自定義數據處理 導入導出總有一些自定義格式轉換,AutoPoi雖然定義了很多服務,但是也無法滿足所有客戶的需求,這個時候就需要咱們自己定義數據處理 AutoPoi提供了 ~~~ /** * Excel 導入導出 數據處理接口 * * @author JueYue * 2014年6月19日 下午11:59:45 */ public interface IExcelDataHandler<T> { /** * 導出處理方法 * * @param obj * 當前對象 * @param name * 當前字段名稱 * @param value * 當前值 * @return */ public Object exportHandler(T obj, String name, Object value); /** * 獲取需要處理的字段,導入和導出統一處理了, 減少書寫的字段 * * @return */ public String[] getNeedHandlerFields(); /** * 導入處理方法 當前對象,當前字段名稱,當前值 * * @param obj * 當前對象 * @param name * 當前字段名稱 * @param value * 當前值 * @return */ public Object importHandler(T obj, String name, Object value); /** * 設置需要處理的屬性列表 * @param fields */ public void setNeedHandlerFields(String[] fields); /** * 設置Map導入,自定義 put * @param map * @param originKey * @param value */ public void setMapValue(Map<String, Object> map, String originKey, Object value); /** * 獲取這個字段的 Hyperlink ,07版本需要,03版本不需要 * @param creationHelper * @param obj * @param name * @param value * @return */ public Hyperlink getHyperlink(CreationHelper creationHelper, T obj, String name, Object value); } ~~~ 簡單的使用方法如下 ~~~ CourseHandler hanlder = new CourseHandler(); hanlder.setNeedHandlerFields(new String[] { "課程名稱" }); exportParams.setDataHandler(hanlder); ~~~ 我們自己實現以下這個類,也可以繼承ExcelDataHandlerDefaultImpl ,避免實現多余的接口 setNeedHandlerFields 這個是需要我們自己處理的字段,需要手動設置 讓我們看一個demo ~~~ public class MapImportHandler extends ExcelDataHandlerDefaultImpl<Map<String, Object>> { @Override public void setMapValue(Map<String, Object> map, String originKey, Object value) { if (value instanceof Double) { map.put(getRealKey(originKey), PoiPublicUtil.doubleToString((Double) value)); } else { map.put(getRealKey(originKey), value != null ? value.toString() : null); } } private String getRealKey(String originKey) { if (originKey.equals("交易賬戶")) { return "accountNo"; } if (originKey.equals("姓名")) { return "name"; } if (originKey.equals("客戶類型")) { return "type"; } return originKey; } } ~~~ 這里我們在map導入的時候把map的key給轉了,從中文轉為習慣的英文
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看