import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class XlsDto2ExcelEx {
/**
*
* @param xls
* XlsDto实体类的一个对象
* @throws Exception
* 在导入Excel的过程中抛出异常
*/
public static void xlsDto2Excel(List<User> xls) throws Exception {
// 获取总列数
int CountColumnNum = 5;
XSSFWorkbook hwb = new XSSFWorkbook();
XSSFCellStyle style = hwb.createCellStyle();
style.setAlignment(XSSFCellStyle.ALIGN_CENTER);
User user = null;
XSSFSheet sheet = hwb.createSheet();
sheet.setColumnWidth(0,256*2*7);//一个汉字两个字符
sheet.setColumnWidth(1,256*2*11);
sheet.setColumnWidth(2,256*2*6);
sheet.setColumnWidth(3,256*2*5);
sheet.setColumnWidth(4,256*2*11);
// sheet 对应一个工作页
// XSSFSheet sheet = hwb.createSheet("pldrxkxxmb");
XSSFRow firstrow = sheet.createRow(0);
XSSFCell[] firstcell = new XSSFCell[CountColumnNum];
String[] names = new String[CountColumnNum];
names[0] = "手机号";
names[1] = "身份证号";
names[2] = "资信平台";
names[3] = "击中规则";
names[4] = "时间";
for (int j = 0; j < CountColumnNum; j++) {
firstcell[j] = firstrow.createCell(j);
firstcell[j].setCellValue(new XSSFRichTextString(names[j]));;
firstcell[j].setCellStyle(style);
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class XlsDto2ExcelEx {
/**
*
* @param xls
* XlsDto实体类的一个对象
* @throws Exception
* 在导入Excel的过程中抛出异常
*/
public static void xlsDto2Excel(List<User> xls) throws Exception {
// 获取总列数
int CountColumnNum = 5;
XSSFWorkbook hwb = new XSSFWorkbook();
XSSFCellStyle style = hwb.createCellStyle();
style.setAlignment(XSSFCellStyle.ALIGN_CENTER);
User user = null;
XSSFSheet sheet = hwb.createSheet();
sheet.setColumnWidth(0,256*2*7);//一个汉字两个字符
sheet.setColumnWidth(1,256*2*11);
sheet.setColumnWidth(2,256*2*6);
sheet.setColumnWidth(3,256*2*5);
sheet.setColumnWidth(4,256*2*11);
// sheet 对应一个工作页
// XSSFSheet sheet = hwb.createSheet("pldrxkxxmb");
XSSFRow firstrow = sheet.createRow(0);
XSSFCell[] firstcell = new XSSFCell[CountColumnNum];
String[] names = new String[CountColumnNum];
names[0] = "手机号";
names[1] = "身份证号";
names[2] = "资信平台";
names[3] = "击中规则";
names[4] = "时间";
for (int j = 0; j < CountColumnNum; j++) {
firstcell[j] = firstrow.createCell(j);
firstcell[j].setCellValue(new XSSFRichTextString(names[j]));;
firstcell[j].setCellStyle(style);