Grails 导出的excel或pdf文件需要页眉

Grails 导出的excel或pdf文件需要页眉,grails,plugins,export-to-excel,export-to-pdf,jasper-plugin,Grails,Plugins,Export To Excel,Export To Pdf,Jasper Plugin,我有一个web应用程序,需要将列表导出为.xlsx或.pdf格式。导出页面时,页面应包含公司的页眉以及列表。怎么可能呢?我在grails中做这个项目。是否有任何插件可以实现这一点。我已经在Grails中尝试了导出插件,但它没有这个功能。我们目前正在使用Grails创建一些到PDF的导出。报告的标题中还包含表格和不同的徽标 我们使用的itext库非常符合我们的要求。您必须知道较新的itext版本不是开源的 下面是一个示例代码段: Document document = new Docume

我有一个web应用程序,需要将列表导出为.xlsx或.pdf格式。导出页面时,页面应包含公司的页眉以及列表。怎么可能呢?我在grails中做这个项目。是否有任何插件可以实现这一点。我已经在Grails中尝试了导出插件,但它没有这个功能。

我们目前正在使用Grails创建一些到PDF的导出。报告的标题中还包含表格和不同的徽标

我们使用的itext库非常符合我们的要求。您必须知道较新的itext版本不是开源的

下面是一个示例代码段:

    Document document = new Document(PageSize.A4)

    def baos= new ByteArrayOutputStream(30)
    def dos= new DataOutputStream(baos)
    PdfWriter writer = PdfWriter.getInstance(document, dos)

    PageNumberEventHelper events = new PageNumberEventHelper()
    writer.setBoxSize("art", new Rectangle(36, 54, 559, 788))
    writer.setPageEvent(events);

    Font titleFont = new Font(Font.UNDEFINED, 22, Font.BOLD)

    document.open()
    // render title
    document.addTitle(getMessage('pricelist.title', [(new Date()).format('dd.MM.yyyy')]));
    document.add(new Paragraph(getMessage('pricelist.title', [(new Date()).format('dd.MM.yyyy')]), titleFont))
    document.add(new Paragraph(' '))

    ...

    document.close()

试试看,您可以制作自己风格的输出

,据我所知,最新的开源版本是itext-2.1.7.jar。