/*
* Copyright (C) 2011-2014 GeoForge Project
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.geoforge.io.file;
import java.io.File;
import java.io.FileOutputStream;
import java.util.List;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
/**
*
* @author bantchao
*/
public class GfrUtilFileExcel extends Object
{
static public void s_doJob(
File fleTarget, List<List> lstLst) throws Exception
{
int intRowCount = 0;
HSSFWorkbook wbk = new HSSFWorkbook();
HSSFSheet sht = wbk.createSheet("First sheet");
Row rowHeader = sht.createRow(intRowCount);
rowHeader.setHeightInPoints(30);
// ---
for (int i = 0; i < lstLst.size(); i++)
{
Row rowCur = sht.createRow(intRowCount);
List<String> lstCur = lstLst.get(i);
for (int j = 0; j < lstCur.size(); j++)
{
Cell celCur = rowCur.createCell(j);
celCur.setCellValue(lstCur.get(j));
}
intRowCount++;
}
// ---
FileOutputStream fos = new FileOutputStream(fleTarget);
HSSFCellStyle cseCellStyle = wbk.createCellStyle();
cseCellStyle.setBorderBottom((short) 1);
cseCellStyle.setFillBackgroundColor((short) 245);
wbk.write(fos);
fos.close();
}
private GfrUtilFileExcel()
{
super();
}
}