【问题标题】:Grails Export plugin set column heightGrails导出插件设置列高
【发布时间】:2013-01-13 04:29:12
【问题描述】:

我正在使用 grails 的导出插件。我的控制器中有这段代码:

    if(params?.format && params.format != "html"){ 
        response.contentType = grailsApplication.config.grails.mime.types[params.format]
        response.setHeader("Content-disposition", "attachment; filename=Pour-Schedule.${params.extension}")
        List fields = ["id", "customer"] 
        Map labels = ["id": "Id", "customer": "Customer"]

        Map parameters = [title: "Customer List", "column.widths": [0.2, 0.3]] 

        exportService.export(params.format, response.outputStream, Customer.list(params), fields, labels, [:], parameters) }

代码column.widths 将设置excel、pdf 等列的宽度。现在如何设置该列的高度?我试过 column.height 但它不工作,所以 row.height。

谁能帮帮我?谢谢。

【问题讨论】:

    标签: grails export


    【解决方案1】:

    不幸的是,据我了解,不支持行的宽度。 见API documentation

    PDF 导出支持一些附加参数,这些参数可以像上面代码示例中的标题属性一样使用。支持以下参数:

    • pdf.encoding(指定字体编码,默认为“Cp1252”(=latin 1),允许值:“Cp1250”、“Cp1252”(=latin 2)、“Cp1257”、“Identity-H”、“Identity -V", "MacRoman") 有关编码的更多信息,请参阅 http://itextdocs.lowagie.com/tutorial/fonts/index.php
    • title.encoding(与 pdf.encoding 相同,但用于标题字体)
    • header.encoding(与 pdf.encoding 相同,但用于标题字体)
    • text.encoding(与 pdf.encoding 相同,但用于文本字体)
    • title.font.size(确定标题字体大小,默认为“10”,允许值:字符串形式的数字)
    • header.font.size(确定标题字体大小,默认为“10”,允许值:字符串形式的数字)
    • text.font.size(确定文本字体大小,默认为“10”,允许值:字符串形式的数字)
    • font.family(确定全局字体系列,允许值:http://www.1t3xt.info/api/com/lowagie/text/FontFactory.html 中定义的常量)
    • title.font.family(确定标题字体系列,默认为 com.lowagie.text.FontFactory.HELVETICA,允许值:http://www.1t3xt.info/api/com/lowagie/text/FontFactory.html 中定义的常量)
    • header.font.family(确定标题字体系列,默认为 com.lowagie.text.FontFactory.HELVETICA,允许值:http://www.1t3xt.info/api/com/lowagie/text/FontFactory.html 中定义的常量)
    • text.font.family(确定文本字体系列,默认为 com.lowagie.text.FontFactory.HELVETICA,允许值:http://www.1t3xt.info/api/com/lowagie/text/FontFactory.html 中定义的常量)
    • title.font.style(确定标题字体样式,默认为“bold”,允许值:“bold”、“italic”、“normal”、“bolditalic”)
    • header.font.style(确定标题字体样式,默认为“bold”,允许值:“bold”、“italic”、“normal”、“bolditalic”)
    • text.font.style(确定文本字体样式,默认为“normal”,允许值:“bold”、“italic”、“normal”、“bolditalic”)
    • border.color(确定表格边框颜色,默认为:new Color(163, 163, 163),允许值:java.awt.Color 对象,例如 Color.RED)
    • separator.color(确定表格行分隔符颜色,默认为:new Color(238, 238, 238),允许值:java.awt.Color 对象,例如 new Color(100, 100, 100))
    • column.widths(以百分比指定列宽,默认为所有列的大小相同,允许的值:浮动列表,例如

    【讨论】:

      【解决方案2】:

      虽然您无法设置单元格高度,但您至少可以使用换行符,以使单元格高度更大。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-02-26
        • 2012-06-21
        • 1970-01-01
        相关资源
        最近更新 更多