67,512
社区成员
发帖
与我相关
我的任务
分享
package com.fastExcel;
import java.io.*;
import java.util.HashMap;
import java.util.Set;
import edu.npu.fastexcel.FastExcel;
import edu.npu.fastexcel.Sheet;
import edu.npu.fastexcel.Workbook;
public class ExportExcelByTemplateUseFastExcel
{
public static void createExcel(String inputFile, String outputFile, String indexFieldName, String dataStartFlag,
Object oData, HashMap hm_var) throws Exception
{
File inFile = new File(inputFile);
File outFile = new File(outputFile);
Workbook outwb = FastExcel.createWriteableWorkbook(outFile);
outwb.open();
Workbook inwb = FastExcel.createReadableWorkbook(inFile);
inwb.open();
Sheet insheet = inwb.getSheet(0);
// 取得EXCEL文件的总行数
int rowCount = insheet.getLastRow() - insheet.getFirstRow();
// 取得Excel文件的总列数
int columnCount = insheet.getLastColumn() - insheet.getFirstColumn();
// 取得列名数组
String[] columFiledNames = new String[columnCount];
String sheetName = (String) hm_var.get("sheetName");
if(sheetName == null || sheetName.trim().equals("")) sheetName = "sheet1";
Sheet outsheet = outwb.addStreamSheet(sheetName);
int flagRow = 0;
/**
* 遍历工作表,替换模板中的变量
* 处理方法:
* 第一步:先把数据区以外的变量替换
* 第二步:替换数据区的变量
*/
}
public static void main(String args[]){
//模板中的变量
HashMap hs = new HashMap();
hs.put("title", "学生基本信息");
hs.put("sheetName", "学生基本信息");
hs.put("lister", "张三");
hs.put("date","2010-04-06");
}
}