package com.zjrs.appcomm.template.excel.mapper;

import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;

import java.util.Map;

/**
 * 简单的数据单元格样式处理
 * 仅仅增加边框
 * @author froms
 *
 */
public class SimpleDataCellStyler implements CellStyler {

	@Override
	public boolean style(Cell cell, Object value, String field, int dataIndex, int rowIndex, int cellIndex, Map<?, ?> row) {
		CellStyle oldCellStyle = cell.getCellStyle();
		CellStyle newCellStyle = cell.getSheet().getWorkbook().createCellStyle();
		newCellStyle.cloneStyleFrom(oldCellStyle);
		newCellStyle.setBorderTop(BorderStyle.THIN);
		newCellStyle.setBorderBottom(BorderStyle.THIN);
		newCellStyle.setBorderLeft(BorderStyle.THIN);
		newCellStyle.setBorderRight(BorderStyle.THIN);
		cell.setCellStyle(newCellStyle);
		return true;
	}

}
