GWT: Export a CellTable to an image or pdf file

余生长醉 提交于 2020-01-06 02:16:48

问题


I have a CellTable showing data that is plotted in a GFlot SimplePlot.

An export of the plot is possible with GFlots integrated function:

    exportImage = plot.getImage();

Now I would like to export the CellTable too, to show the corresponding data to the plot. Is this possible in some way with GWT on the client-side? It needn't to be the CellTable itself, just the data it shows would suffice.


回答1:


I think You can use flash4j library:

package com.emitrom.flash4j.demo.client;

import com.emitrom.flash4j.clientio.client.ClientIO;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.RootPanel;

public class ClientIOExample implements EntryPoint {
@Override
public void onModuleLoad() {
    // initialize the ClientIO module
    ClientIO.init();

    Button b = new Button("Click Me");
    b.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            // create a PDF File
            PDF pdf = new PDF();
            pdf.addPage();
            pdf.setTextStyle(new RGBColor(0x000000));
            pdf.setFont(new CoreFont(), 10);
            pdf.addText("");
            ClientIO.saveFile(pdf.save(), "file.pdf");
        }
    });
    RootPanel.get().add(b);
}
}

You can see more detailed information a link



来源:https://stackoverflow.com/questions/12334257/gwt-export-a-celltable-to-an-image-or-pdf-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!