Creating a document/pdf of the contents in the list or table..

Hi…

I have a requirement of creating a document or pdf of the list of items listed in the table…
Suggest a solution.
Thank You.

Hi,

My suggested solution: Write code to create a document or a PDF of the items listed in the table. :slight_smile:

There is already a
plugin to create an spreadsheet from a table
. If that doesn’t meet your needs in it’s existing form, you could adapt the source code, or at least read how it uses the table to get at the underlying data - or even extend TableExport (which has useful code on returning files to the browser) to export the table to PDF (using iText or similar).

Cheers,

Charles.

[Updated Later]
Oh, I see you’re already trying to use the TableExport plugin. Still, I think this message is still relevant and may be useful to others who search the forum. Note to self: catch-up on all forum messages before replying!

Thank You Charles…

I had configured the table export plugin and its working fine. But not displaying generated column contents.
Tried exportableColumnGenerator but couldnt know how to get the getGeneratedProperty() value…

can you tell me how to get the generated property from itemId and columnId
(I meant the content for getGeneratedProperty(Object itemId, Object ColumnId ) )

Pls help me as I need to implement ASAP…

I’ve never done this - as I don’t actually use the add-on.
I’ve downloaded it.
I looked at the source, inside the jar.

There is an example application there which shows you how to implement the column generator. I’ve extracted it and pasted it below. It looks quite simple to me - it appears to be separating out the calculation of the
value
to display from the creation of the
component
to display in the column. I imagine that the TableExport looks at the result of the getGeneratedProperty (and getType) to display the value and format it in the spreadsheet.

The TableExport component can’t just look at any arbitrary component to work out what to display (which is all that the standard ColumnGenerator allows the caller to generate), it has to have access to the actual data you want to display.

I can’t offer any more help. All I’d be doing is reading the code - which, I have to say, I recommend you do. It’s not complex, and would help your understanding of what’s going on immensely.

Cheers,

Charles.


        table.addGeneratedColumn("taxes", new ExportableColumnGenerator() {
            private static final long serialVersionUID = -1591034462395284596L;

            @Override
            public Component generateCell(final Table source, final Object itemId,
                    final Object columnId) {
                final Property prop = getGeneratedProperty(itemId, columnId);
                Label label;
                final Object v = prop.getValue();
                if (v instanceof Double) {
                    label = new Label(df.format(v));
                } else {
                    label = new Label(prop);
                }
                return label;
            }
            @Override
            public Property getGeneratedProperty(final Object itemId, final Object columnId) {
                final PayCheck p = (PayCheck) itemId;
                final Double tax = .0825 * p.getAmount();
                return new ObjectProperty<Double>(tax, Double.class);
            }
            @Override
            public Class<?> getType() {
                return Double.class;
            }
        });

Thank You Charles…Will try out the sample as you said.

Is it possible to edit the ExportableColumnGenerator in tableExport addon…

Only with itemId and columnId its not possible to work in my case.
I need the table source, such like (getGeneratedProperty(Table source, Object ItemId, Object columnId))

you can pass the Table in the constructor of your ExportableColumnGenerator implementation, or make it final and read inside your method

Hi Danny, you meant to edit the exportableColumnGenerator in jar file ?

Its an inteface, which you can implement and in your implementation you pass the table as constructor argument