Vaadin spreadsheet

Hello, I’m considering integrating the Vaadin spreadsheet into my application and was wondering how it would work. I think I will have to “unwrap” it to populate the spreadsheet. I was wondering how I would store the save spreadsheet in an entity. Will it work or will everything have to be dynamic? Thanks.

Hi Francis,
please take a look at [url=https://doc.cuba-platform.com/manual-6.0/vaadin_addon_sample.html]https://doc.cuba-platform.com/manual-6.0/vaadin_addon_sample.html[/url].
In case of Vaadin Spreadsheet we need to:
1. Add dependency to Project using Studio Project properties
Go to Project properties section.
Click on Edit.
Open tab Advanced.
Add maven dependency string to module web with configuration compile: com.vaadin.addon:vaadin-spreadsheet:1.1.6
2. Create toolkit module
Click on link “Create web toolkit module”.
New GWT client side module will be added to your project.
3. Add widgetset item to widgetset XML
Open your project in IDE.
Go to web-toolkit module.
Find AppWidgetSet.gwt.xml file.
Add inherits tag to module

     
   <?xml version="1.0" encoding="UTF-8"?>     
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.7.0//EN"     
        "[url=http://google-web-toolkit.googlecode.com/svn/tags/1.7.0/distro-source/core/src/gwt-module.dtd]http://google-web-toolkit.googlecode.com/svn/tags/1.7.0/distro-source/core/src/gwt-module.dtd">[/url];     
<module>     
    <inherits name="com.haulmont.cuba.web.toolkit.ui.WidgetSet" ></inherits>   
    <inherits name="com.vaadin.addon.spreadsheet.Widgetset"></inherits>   
</module>     


4. Create theme extension to include CSS styles from Vaadin addon
Click on link “Create theme extension”.
Select “halo” and click OK.
5. Add include of spreadsheet to halo-ext.scss
Open your IDE.
Find modules/web/themes/halo/halo-ext.scss file
Change it to include styles from Spreadsheet:

     
    @import "../halo/halo";     
    @import "../../../VAADIN/addons/spreadsheet/spreadsheet.scss";     
    /* Define your theme modifications inside next mixin */     
    @mixin halo-ext {     
      @include halo;     
      @include spreadsheet;     
    }     


6. Obtain spreadsheet license
After this we need to fetch a license for Vaadin Spreadsheet in order to be able to compile the widget set. You can get a free trial key from Vaadin Directory. Click the large orange “Free trial key” button to the right and copy and paste the key into a file named vaadin.spreadsheet.developer.license in your home directory.
Now we can assemble our project and create screens with Spreadsheet component. Compile time will be increased due to custom GWT widget set, but no need to worry, it will be greater than usual only if you build your project after clean checkout.
I’ve prepared sample project, so you can see how to add Spreadsheet to CUBA project. Don’t forget to obtain Vaadin Spreadsheet trial version to run sample.
Spreadsheet Addon mainly aimed on work with XLS files and if you need to set data to CUBA entities from Spreadsheet you should explore API of Spreadsheet and Apache POI library used by this Addon.

vaadin-spreadsheet.zip (24.0K)

Thank Yuriy for your detailed explanation. I was able to follow the steps all the way to the end. I looked at your project but it seems to be empty.

If you could reattach your project or send me some sample code, that would be great. Thank you.

Sorry for the inconvenience, I’ve reattached project archive.

Are you going to reattach the project? Thanks.

I’ve reattached project to my first comment. Copy here.

The project is empty.
Can you copy and paste the code here?

Sorry, I have strange problem with my file system. I’ve attached working version.


<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<window xmlns="http://schemas.haulmont.com/cuba/window.xsd"
        caption="msg://caption"
        class="com.company.vaadinspreadsheet.web.demo.SpreadsheetDemo"
        messagesPack="com.company.vaadinspreadsheet.web.demo">
    <layout expand="spreadsheetContainer">
        <button caption="Test" invoke="readSpreadsheet"/>
        <vbox id="spreadsheetContainer">
        </vbox>
    </layout>
</window>

public class SpreadsheetDemo extends AbstractWindow {
    @Inject
    private VBoxLayout spreadsheetContainer;

    private Spreadsheet spreadsheet;

    @Override
    public void init(Map<String, Object> params) {
        super.init(params);

        spreadsheet = new Spreadsheet();

        spreadsheet.createCell(0, 0, "Spreadsheet");
        spreadsheet.createCell(0, 1, 12.7);

        ComponentContainer vContainer = (ComponentContainer) WebComponentsHelper.unwrap(spreadsheetContainer);
        vContainer.addComponent(spreadsheet);
    }

    public void readSpreadsheet() {
        showNotification("Read from Spreadsheet", "Defined rows: " +
                spreadsheet.getActiveSheet().getPhysicalNumberOfRows(), NotificationType.HUMANIZED);
    }
}

vaadin-spreadsheet.zip (24.0K)

Thank you. It worked great.

Hi Hello,
When i try to import the Project: vaadin-spreadsheet.zip file, i am getting the following error…

Untitled-1%20copy

Please help me regarding this…