现在定义模板如下
[img]http://dl.iteye.com/upload/attachment/0083/8208/f1152188-542b-3409-85b5-69f2a50ebca0.jpg[/img]
现在贴出关键代码
[code="java"]
Workbook wb = new Workbook(template_file_path);
WorkbookDesigner designer = new WorkbookDesigner();
designer.setWorkbook(wb);
/* Map person = new HashMap();
person.put("id", "id");
person.put("name", "name");*/
Person person = new Person("1" , "jack");
designer.setDataSource("Person", person);
designer.process(true);
return wb;
[/code]
第一个问题????
现在的问题是设置Person person = new Person("1" , "jack");实体类可以正确导出excel
但是设置hashMap 就不能导出 有时报表比价复杂 用hashMap更灵活些 有什么办法解决
第二个问题????
[code="java"]
public class DataTable implements ICellsDataTable
{
private ArrayList list = null;
private int index;
public DataTable()
{
list = new ArrayList<Person>();
for(int i = 0; i < 10; i++)
{
Person person = new Person("" + i, "Person" + i);
list.add(person);
}
index = -1;
}
public String[] getColumns()
{
return new String[]
{
"id", "name"
};
}
public int getCount()
{
return this.list.size();
}
public void beforeFirst()
{
index = -1;
}
public Object get(int columnIndex)
{
if(index < 0 || index >= this.getCount())
{
return null;
}
Person person = this.list.get(index);
switch (columnIndex)
{
case 0:
return person.getId();
case 1:
return person.getName();
default:
return null;
}
}
public boolean next()
{
index += 1;
if(index >= this.getCount())
{
return false;
}
return true;
}
//这个方法为什么不执行呢 执行的是public Object get(int columnIndex)
// 我希望执行public Object get(String columnName)这个方法,这样我就可以写一个通用的方法
/**
* Returns the value of the designated column in the current row.
*
* @param columnName
* the property name of the POJO.
* @return the value of the designated column in the current row.
*/
public Object get(String columnName)
{
Person person = this.list.get(index);
if(columnName.equals("id"))
{
return person.getId();
}
if(columnName.equals("name"))
{
return person.getName();
}
return null;
}
}
[/code]
最后一个问题???
是如何在模板中定义图片 然后填充进去,像那种个人简历的模板