haiwan / exporter Goto Github PK
View Code? Open in Web Editor NEWA Vaadin Add-on which exports data (in container) to an excel file
License: Other
A Vaadin Add-on which exports data (in container) to an excel file
License: Other
Column header text in exported excel is different from set column header text in vaadin grid.
Exporter in current state use column key to find property and use property name.
I added proposal for custom column headers in exported excel in pull request #24
Tested with vaadin 13.
Numbers represented as a string in the exported sheet can not be used in math calc if needed. Sorting and filtering not possible.
The same for dates.
Hello,
Thanks for this addon, it is really great.
I don't want to add a specific button on the bottom of my view, so I would like to add ExcelExporter as Action.Handler(right click) of my Table. Do you know a way to achieve that?
Thanks!
Hi,
Thank you for your great addon. I like this very much. Is there any way you can also generate pdfs for vaadin grid?
The Exporter 2.0.2 go to error when the column of the grid has nested property ("town.name" for example) and first property is null (town == null for example). The vaadin grid 8.9.3 permits it with NestedNullBehavior.ALLOW_NULLS option:
example:
column = grid.addColumn("town.name", renderer, NestedNullBehavior.ALLOW_NULLS);
Encoding of CSV is differently by OS. Now for Linux - UTF-8, for Windows - ANSI. I want to same encoding for all OS. How to set own encoding format to content of CSV?
Some projects fail to be resolved
Impossible to resolve dependencies of com.example#v7proj;working@mako_laptop
unresolved dependency: org.vaadin.addons#exporter;0.0.5.4: java.text.ParseException: inconsistent module descriptor file found in 'http://maven.vaadin.com/vaadin-addons/org/vaadin/addons/exporter/0.0.5.4/exporter-0.0.5.4.pom': bad revision: expected='0.0.5.4' found='0.0.3.1';
Using IVY
Hi I get an error if I don't provide the visible colums.
(see stack trace). If I provide them, I just get an empty file.
Could you please help.$
thx
java.lang.NullPointerException
at org.vaadin.haijian.filegenerator.FileBuilder.buildColumnHeaders(FileBuilder.java:80)
at org.vaadin.haijian.filegenerator.FileBuilder.buildFileContent(FileBuilder.java:70)
at org.vaadin.haijian.filegenerator.FileBuilder.getFile(FileBuilder.java:53)
at org.vaadin.haijian.Exporter.getStream(Exporter.java:101)
at com.vaadin.server.StreamResource.getStream(StreamResource.java:141)
at com.vaadin.server.FileDownloader.handleConnectorRequest(FileDownloader.java:140)
at com.vaadin.server.ConnectorResourceHandler.handleRequest(ConnectorResourceHandler.java:83)
There is a problem with setting the setting of the dateformat of the exporter.
The dateformat is used in the fileBuilder but when you initialise the exporter with the data container the filebuilder is created and the method 'setDateFormat' does not update this filebuilder, thus this dateformat is not used.
ex.
This will not work:
excelExporter = new ExcelExporter(table.getContainerDataSource(), table.getContainerDataSource().getContainerPropertyIds().toArray());
excelExporter.setDateFormat("dd-MM-yyyy");
This works:
excelExporter = new ExcelExporter();
excelExporter.setDateFormat("dd-MM-yyyy");
excelExporter.setContainerToBeExported(table.getContainerDataSource());// here the fileBuilder is created and the dateformat of this builder is set!!!
excelExporter.setVisibleColumns(table.getContainerDataSource().getContainerPropertyIds().toArray());
Kind regards,
Erik
I downloaded latest 0.0.5.5 plugin, included in my Report view and upon runnin, I am getting this error. Can someone explain me why am I getting this issue? It sees getDownloadFileName method is having some issue?
Caused by: java.lang.NullPointerException
at org.vaadin.haijian.Exporter.setDownloadFileName(Exporter.java:106)
at com.prod_dc.views.LoginView$1.selectedTabChange(LoginView.java:166)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:508)
... 59 more
Export throws an Exception in exportAsExcel :
java.lang.NoSuchMethodError: org.apache.poi.ss.usermodel.Font.setBoldweight(S)V
at org.vaadin.haijian.ExcelFileBuilder.getBoldStyle(ExcelFileBuilder.java:82)
at org.vaadin.haijian.ExcelFileBuilder.buildColumnHeaderCell(ExcelFileBuilder.java:76)
mabe due to the fact that there is another depebdency POI ( 3.17 ) on my Classpath.
My application isn't pure Vaadin, so some are mapped to something else, and some for Vaadin
That's my web.xml:
default
org.apache.catalina.servlets.DefaultServlet
debug
1
listings
true
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/log_in</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/Styles/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/Images/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/Scripts/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>EpaymentUI</servlet-name>
<servlet-class>com.vaadin.server.VaadinServlet</servlet-class>
<init-param>
<description>Vaadin UI class to use</description>
<param-name>UI</param-name>
<param-value>com.gizasystems.stcepayment.ui.EpaymentUI</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>EpaymentUI</servlet-name>
<url-pattern>/VAADIN/*</url-pattern>
</servlet-mapping>
now each time i call the exporter i always get this error:
com.vaadin.server.VaadinServlet serveStaticResourcesInVAADIN
INFO: Requested resource [/VAADIN/APP/connector/1/42/dl/exported-excel.xls] not found from filesystem or through class loader. Add widgetset and/or theme JAR to your classpath or add files to WebContent/VAADIN folder.
what should i do?
To obtan header text, now, you read the Column Name by default. Can you read Captions with an option?
Hi,
One thing I noticed is that this add-on does not allow proper heading to be exported in .pdf or excel format... For example
if I have column with name Sample 1 Sample 2 ... Sample 10 Sample 11 then it displays:
Sample 1 Sample 10 Sample 11 Sample 2 ... and so on.
How do you avoid such sorting?
Can we do something like this:
excelExport.setColumnSorting(false); ??
In Exporter there is the constructor with one argument - Container container. This calls the constructor with two arguments - Container container, Object[] visibleColumns , with null value for visibleColumns. In this constructor, the call this.setContainerToBeExported(container) , eventually creates the FileBuilder and ends up in the setContainer(container) method which also set's the visibleColumns. Then in the same constructor you set again the visibleColumns, to null this time, because it is the value passed in as parameter.
This leads to NPE in FileBuilder in methods like buildColumnHeaders, where you check the length on the visibleColumns array which is in fact null - if (this.visibleColumns.length != 0) .
My solution:
public Exporter(Container container, Object[] visibleColumns) {
this();
this.setCaption("Exporter");
//set visible columns first
this.setVisibleColumns(visibleColumns);
//then, the container
this.setContainerToBeExported(container);
}
I am running Vaadin 8 and using version 2.0.2 I export a grid in Excel. I also use ExporterOption as indicated in the release notes. However, it does not work as inclined. More specifically, I am not able to change the name of the column in the exported excel file, whatever I try.
If you are on a table or grid and export it to Excel, it works fine. If you then refresh the data in the grid/table, it often downloads the same exact file. Even setting the name using setDownloadFileName("newname.xls");
does not work because by that time the FileDownloader
is already created and will never get refreshed until you leave the screen and come back. Since fileDownloader
is private, I cannot call fileDownloader.setCacheTime(0);
to get around this issue, as per vaadin/framework#10909. I think the simplest solution would be to change this from private
to protected
. I am pretty sure if it was protected, I could sub-class it and just call fileDownloader.setCacheTime(0);
to get around the issue. Is that possible, or am I missing something?
The filter in DataCommunicator is null when buildRows method is called even though I have set filter in grid and can see a CrudFilter in the DataProvider while debugging.
Your pom for version 0.0.5.4 has a version "0.0.3.1":
0.0.3.1
This made our artifactory cache repository go crazy.
Would it be possilbe to export data in SPSS format as well?
Is there a way to export dates as dates to Excel? I am not talking about the format of the date, as MM/DD/YYYY, which the API already handles. I am talking about the resulting Excel. Right now, the data type is "General" when you right click the cell in Excel, unless you actually edit the date column. Once you edit it, it is in the proper Excel "Date" type, and is right justified in the Excel Cell.
In the code, we have setDateFormat("MM/dd/yyyy");
, so the Excel looks correct. It is purely the Excel column type that is the problem.
BTW, using version 1.0.1 for a Vaadin 7 application.
I attached the screen I am exporting, with a date column, and the corresponding excel export, to explain what I mean.
Are there plans to make a V7 compatibility mode for those converting from Vaadin7 to Vaadin8?
Multiple containers to the Exporter??
Export in .csv format does not work correctly: multi-line values are written not to one cell, but row by row to several cells. For example, the following id will take three cells: id =
"asdasd-
asdasd-
asdasd".
Xlsx export does not have this problem.
When export button is clicked multiple times just first click produce excel with header row. Every other click after first does not have header row.
Proposed solution is in second commit in #24
Any plan to support Vaadin 8 Grid?
I am looking for the export functionality Vaadin 8 Grid data to the comma delimited file.
If no plan for supporting Vaadin 8 Grid soon, then any other suggestion?
Jennifer.
I'm generating a PDF export of a table with multiple columns and for some strange reason some of the exported cells have values like "com.vaadin.ui.Label@5d25c914" instead of the correct value.
I noticed that this behavoir occurs before a formatted column (date format or amount format) and causing the cells to shift so they don't correspont to their column headers.
Excel export works correctly.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.