我在Railo 3.3.1.000上使用jopendocument 1.2
来自http://www.jopendocument.org/start_text_2.html
List<Map<String, String>> months = new ArrayList<Map<String, String>>();
months.add(createMap("January", "-12", "3"));
months.add(createMap("February", "-8", "5"));
months.add(createMap("March", "-5", "12"));
months.add(createMap("April", "-1", "15"));
months.add(createMap("May", "3", "21"));
template.setField("months", months);如何用cfml编写代码,或者任何有使用jopendocument经验的人都可以用cfml在odt模板文件中添加行?
发布于 2011-11-25 03:45:56
List<Map<String, String>> months = new ArrayList<Map<String, String>>();
在CF术语中,该代码创建了一个结构数组。因为java是强类型的,所以代码使用泛型来指示每个对象包含的对象类型。
List< Map<...> > // Array containing structures
Map< String, String > // Structure containing "String" values幸运的是,CF数组在内部是java.util.List对象,结构是java.util.Map对象。因此,您只需要使用正确的键和值创建一个CF结构数组。然后将数组传递给template.setField(...)。
我不确定在结构中使用哪些键,所以我从jOpenDocument-template-1.2.zip下载了"test.odt“模板。它揭示了每个结构应该包含三(3)个键,表中的每一列都有一个键:name,min,max。只要你用字符串填充结构,这应该是可行的:
// Create an array of structures. Each structure represents a table row.
// The key names for columns 1-3 are: "name", "min", "max"
months = [
{name="January", min="-12", max="3"}
, {name="February", min="-8", max="5"}
, {name="March", min="-5", max="12"}
, {name="April", min="-1", max="15"}
, {name="May", min="3", max="21"}
, {name="June", min="5", max="32"}
];
// populate table rows
template.setField("months", months);https://stackoverflow.com/questions/8254547
复制相似问题