forked from fanruan/easyexcel
zhuangjiaju
6 years ago
16 changed files with 283 additions and 105 deletions
@ -1,8 +1,9 @@
|
||||
package com.alibaba.excel.converters; |
||||
|
||||
import java.util.Collection; |
||||
import java.util.Map; |
||||
|
||||
public interface ConverterRegistryCenter { |
||||
void register(Converter converter); |
||||
Collection<Converter> getConverters(); |
||||
Map<ConverterKey, Converter> getConverters(); |
||||
} |
||||
|
@ -0,0 +1,38 @@
|
||||
package com.alibaba.excel.converters; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
import com.alibaba.excel.converters.bigdecimal.BigDecimalNumberConverter; |
||||
import com.alibaba.excel.converters.date.DateStringConverter; |
||||
|
||||
/** |
||||
* Build default handler |
||||
* |
||||
* @author zhuangjiaju |
||||
*/ |
||||
public class DefaultConverterBuilder { |
||||
/** |
||||
* Load default wirte converter |
||||
* |
||||
* @return |
||||
*/ |
||||
public static Map<Class, Converter> loadDefaultWriteConverter() { |
||||
Map<Class, Converter> converterMap = new HashMap<Class, Converter>(); |
||||
DateStringConverter dateStringConverter = new DateStringConverter(); |
||||
converterMap.put(dateStringConverter.supportJavaTypeKey(), dateStringConverter); |
||||
BigDecimalNumberConverter bigDecimalNumberConverter = new BigDecimalNumberConverter(); |
||||
converterMap.put(bigDecimalNumberConverter.supportJavaTypeKey(), bigDecimalNumberConverter); |
||||
return converterMap; |
||||
} |
||||
|
||||
/** |
||||
* Load default read converter |
||||
* |
||||
* @return |
||||
*/ |
||||
public static Map<ConverterKey, Converter> loadDefaultReadConverter() { |
||||
Map<ConverterKey, Converter> converterMap = new HashMap<ConverterKey, Converter>(); |
||||
return converterMap; |
||||
} |
||||
} |
@ -0,0 +1,37 @@
|
||||
package com.alibaba.excel.metadata; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
import org.apache.poi.ss.usermodel.CellStyle; |
||||
|
||||
/** |
||||
* Excel基础模型 |
||||
* |
||||
* @author jipengfei |
||||
* @deprecated Now you don't need to extend any classes |
||||
*/ |
||||
@Deprecated |
||||
public class BaseRowModel { |
||||
|
||||
/** |
||||
* 每列样式 |
||||
*/ |
||||
private Map<Integer, CellStyle> cellStyleMap = new HashMap<Integer, CellStyle>(); |
||||
|
||||
public void addStyle(Integer row, CellStyle cellStyle) { |
||||
cellStyleMap.put(row, cellStyle); |
||||
} |
||||
|
||||
public CellStyle getStyle(Integer row) { |
||||
return cellStyleMap.get(row); |
||||
} |
||||
|
||||
public Map<Integer, CellStyle> getCellStyleMap() { |
||||
return cellStyleMap; |
||||
} |
||||
|
||||
public void setCellStyleMap(Map<Integer, CellStyle> cellStyleMap) { |
||||
this.cellStyleMap = cellStyleMap; |
||||
} |
||||
} |
@ -0,0 +1,38 @@
|
||||
package com.alibaba.excel.write.handler; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import org.apache.poi.ss.usermodel.IndexedColors; |
||||
|
||||
import com.alibaba.excel.metadata.CellStyle; |
||||
import com.alibaba.excel.metadata.Font; |
||||
import com.alibaba.excel.write.style.RowCellStyleStrategy; |
||||
import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy; |
||||
|
||||
/** |
||||
* Build default handler |
||||
* |
||||
* @author zhuangjiaju |
||||
*/ |
||||
public class DefaultWriteHandlerBuilder { |
||||
|
||||
/** |
||||
* Load default handler |
||||
* |
||||
* @return |
||||
*/ |
||||
public static List<WriteHandler> loadDefaultHandler() { |
||||
List<WriteHandler> handlerList = new ArrayList<WriteHandler>(); |
||||
CellStyle headCellStyle = new CellStyle(); |
||||
Font font = new Font(); |
||||
headCellStyle.setFont(font); |
||||
font.setFontName("宋体"); |
||||
font.setBold(true); |
||||
headCellStyle.setIndexedColors(IndexedColors.GREY_25_PERCENT); |
||||
handlerList.add(new RowCellStyleStrategy(headCellStyle, new ArrayList<CellStyle>())); |
||||
handlerList.add(new SimpleColumnWidthStyleStrategy(20)); |
||||
return handlerList; |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue