首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将jopendocument与coldfusion/railo结合使用,如何添加表行?

将jopendocument与coldfusion/railo结合使用,如何添加表行?
EN

Stack Overflow用户
提问于 2011-11-24 17:12:21
回答 1查看 476关注 0票数 3

我在Railo 3.3.1.000上使用jopendocument 1.2

来自http://www.jopendocument.org/start_text_2.html

代码语言:javascript
复制
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模板文件中添加行?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-11-25 03:45:56

List<Map<String, String>> months = new ArrayList<Map<String, String>>();

在CF术语中,该代码创建了一个结构数组。因为java是强类型的,所以代码使用泛型来指示每个对象包含的对象类型。

代码语言:javascript
复制
    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)个键,表中的每一列都有一个键:nameminmax。只要你用字符串填充结构,这应该是可行的:

代码语言:javascript
复制
// 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);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8254547

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档