package mobvista.prd.datasource.newall;

import com.google.common.collect.Lists;
import org.apache.poi.hssf.usermodel.*;

import java.io.*;
import java.util.List;

/**
 * Created by Administrator on 2017/4/29 0029.
 */
public class InterestTable {
    public static void main(String[] args) throws IOException {
        List<String> interestList = readInterest("E:\\prd\\test/interestAll.txt");
        FileOutputStream fos = new FileOutputStream("E:\\prd\\test/兴趣.xls");
        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFSheet s = wb.createSheet();
        int columnHead = 0;
        int rowLine = 0;
        HSSFRow rowOne = s.createRow(0);
        for (String column : interestList) {
            HSSFRow row = s.createRow(rowLine);
            String[] fields = column.split("\t",-1);
            columnHead = 0;
            for (String line : fields) {
                HSSFCell cell = row.createCell(columnHead, 0);
                HSSFRichTextString hts = new HSSFRichTextString(line);
                cell.setCellValue(hts);
                columnHead++;
            }
            rowLine++;
        }
        wb.write(fos);
        fos.flush();
        fos.close();
    }
    public static List readInterest (String path) throws IOException {
        List interestList = Lists.newArrayList();

        FileReader fr = new FileReader(path);
        BufferedReader br = new BufferedReader(fr);
        String s = br.readLine();
        while (s != null) {
            interestList.add(s);
            s = br.readLine();//再读下一行
        }
        return interestList;
    }
}
