Vaadin Spreadsheets write problem

Hi,

I tried save an excel file edited with vaadin spreadsheet

 private static String MY_FILE_PATH = "C:/Users/Luca/Excels/my_tables.xlsx";
 
 mySpreadsheetFile = new File(MY_FILE_PATH);
try {
 Spreadsheet mySpreadsheet = new Spreadsheet(mySpreadsheetFile);

    } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
    }
[...]


 mySpreadsheet.write(SPREADSHEET_FILE_PATH);

but i got this exception:

org.apache.poi.POIXMLException: java.io.IOException: Can't obtain the input stream from /docProps/app.xml
    at org.apache.poi.POIXMLDocument.getProperties(POIXMLDocument.java:148)
    at org.apache.poi.POIXMLDocument.write(POIXMLDocument.java:199)
    at com.vaadin.addon.spreadsheet.SpreadsheetFactory.write(SpreadsheetFactory.java:285)
    at com.vaadin.addon.spreadsheet.Spreadsheet.write(Spreadsheet.java:2161)
    at it.datariver.sharedkontrol.component.HeritageMainPanel$2.onCellValueChange(HeritageMainPanel.java:435)
    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)
    at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:198)
    at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161)
    at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:977)
    at com.vaadin.addon.spreadsheet.Spreadsheet.fireEvent(Spreadsheet.java:591)
    at com.vaadin.addon.spreadsheet.CellValueManager.fireCellValueChangeEvent(CellValueManager.java:590)
    at com.vaadin.addon.spreadsheet.CellValueManager.onCellValueChange(CellValueManager.java:558)
    at com.vaadin.addon.spreadsheet.SpreadsheetHandlerImpl.cellValueEdited(SpreadsheetHandlerImpl.java:138)
    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.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:168)
    at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:118)
    at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:291)
    at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:184)
    at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:92)
    at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)
    at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1408)
    at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:350)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1448)
    at net.sf.ehcache.constructs.web.filter.GzipFilter.doFilter(GzipFilter.java:95)
    at net.sf.ehcache.constructs.web.filter.Filter.doFilter(Filter.java:86)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1419)
    at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:119)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1419)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
    at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
    at org.eclipse.jetty.server.Server.handle(Server.java:370)
    at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)
    at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:960)
    at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1021)
    at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:865)
    at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
    at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:668)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
    at java.lang.Thread.run(Thread.java:662)
Caused by: java.io.IOException: Can't obtain the input stream from /docProps/app.xml
    at org.apache.poi.openxml4j.opc.PackagePart.getInputStream(PackagePart.java:500)
    at org.apache.poi.POIXMLProperties.<init>(POIXMLProperties.java:75)
    at org.apache.poi.POIXMLDocument.getProperties(POIXMLDocument.java:146)
    ... 61 more

Any idea?

I solved it!

I had to change constructor:
indeed
Spreadsheet(File file)
allows to read an excel file, but it generates a POIXMLException on write.
I had to create
XSSFWorkbook
and setting it to the Spreadsheet :

            mySpreadsheet = new Spreadsheet();
            wb = new XSSFWorkbook(new FileInputStream(mySpreadsheetFile));
            heritageSpreadsheet.setWorkbook(wb);

I am facing the same issue.CAn you please provide solution in more detail how you have fixed it

You have to you use XSSFWorkbook (org.apache.poi.xssf.usermodel.XSSFWorkbook)
and create a new instance, passing a FileInputStream in the constructor.

nullpointer occured in vaadin spreadsheet when i create new sheet and cells and merge that cells

This looks not related to the original post, can you post it in a separate thread and add an example of what you’re trying to do with the corresponding stack trace?

cell backgrond colour are not comes when we export as file

FIY
31228.xls (6.1 KB)