Logo text Governance.io - Governance.com
  • Benefits

  • Information

  • Customer area

  • More...

    • Benefits
      • Information
        • Careers
          • Contact
          • Customer area
            • License order form
              • Cart
                • General terms and conditions
                  • Privacy Policy
                    • User Agreement
                    LINKS
                    ABOUT
                    SOCIAL
                    • Grey Twitter Icon
                    • Grey Facebook Icon
                    • Grey LinkedIn Icon

                    2Gears S.A.

                    Creators of Governance.io - Governance.com

                    ​

                    Visiting address:

                    29, Boulevard GD Charlotte

                    "The Office"

                    L-1331 Luxembourg

                    ​

                    Registered address:

                    17, Boulevard Prince Henri

                    L-1724 Luxembourg

                    VAT: LU28166771
                    RCS: B0164267 

                    © 2016 2Gears SA

                    Logo Governance.io - Governance.com
                    THE PLATFORM

                    IMF: Luxembourg Financial Sector Assessment Program 2017

                    September 2, 2017

                    The Innovators — A Conversation with Bert Boerman, CEO of Governance.io

                    August 3, 2017

                    Governance.io welcomes Business Development Director Olus Kayacan

                    June 16, 2017

                    Trident Trust applies RegTech to lead in Alternative Investment Fund services

                    June 9, 2017

                    Governance.io listed on the European Hot Ten list of FinTech50

                    June 7, 2017

                    Governance.io team at ICT Spring in Luxembourg

                    May 23, 2017

                    Sneak preview of Governance.io VisualWorkBench™

                    April 8, 2017

                    Bert Boerman selected as RegTech book author

                    March 22, 2017

                    A TASTE OF FINTECH FROM 2 ANGLES... AND 2 SIDES OF THE WORLD

                    March 17, 2017

                    FINTECH AWARDS 2017 - who will take over the title "FinTech Startup of the Year" from Governance.io?

                    March 15, 2017

                    Please reload

                    Recent Posts
                    Tips and tricks

                    Ext JS Excel Import Export made easy

                    August 18, 2014

                    mporting and exporting Excel documents from your ExtJS apps has never been easier.

                     

                    TL;DR

                    So you’re in a hurry right? Then cut the chase and see for yourself how easy it is.

                     

                    Gears

                    Gears are hyper productivity tools  aimed at dramatically speeding up software development. Some Gears are standalone pieces of code that solve a particular problem. Other Gears are development tools to aid the developer to work more efficiently with their code, the framework or related tools. The Import-Export Gear helps Ext JS developers import and export Excel data files, such as CSV and XLS(X) by just dropping in a package and adding a handful of lines of code.

                     

                    Dreadful data

                    Data driven applications like CRM systems are only as good as the data they operate on. Typically there are 2 hard-to-solve problems;  1. getting large amounts of data into the system and 2. exporting data from the system to be able to share it with external systems or people. Many companies use spreadsheets to enter, store and distribute data. This means that import and export is not just a one-of task but an ongoing requirement of the application. Manually copy-pasting between the application and Excel is enough to drive any person crazy. Yet, in most companies that is exactly what is happening. State of the art systems are designed but when data has to imported or exported, we seem to jump back to 1998 and do it manually. So why aren’t there any good tools around to help application developers with this?

                     

                    Working with files is hard

                    Since web applications run inside the client’s browser, javascript (and thus Ext JS) can never access files on the client’s machine, because of security reasons. The first hurdle is getting the file data into our application. Usually this is solved by uploading the file to a server, inserting the data into the server’s database or parsing it in memory and then returning the data to the client. When the client application is finished working on the data it is sent back to the server. In an Ext JS application, you’ll need to create a store, a grid, and a model that exactly match the structure of your data file. You’ll also need a custom way of uploading the file to the server, and a proxy to read and write the application data. This is already a lot of work, but it gets worse:

                    1. You’ll need to create a new server side importer for every structure of data you want to import.

                    2. Your server is doing the heavy lifting. The more users upload files simultaneously, the more processing power you will need or the requests will just start queuing up.

                    3. Your server is polluting its database with records with every file import before the client is actually finished working on it.

                    4. Any typos or other discrepancies between the file data headers and the fields of your model and your import will fail.

                    5. Reading this paragraph probably took you longer than implementing an entire solution using our Gearbox Import Export Gear.

                    The last is a bold claim, so please allow us to show you how easy working with files can be.

                     

                    Working with files is easy with Gearbox

                    With the Gearbox Import / Export Gear, you can create an Ext JS application that can import excel files in under 2 minutes. Oh, and while you’re at it, you’ll add CSV support and export functionality as well, still well under 2 minutes, and in less than 50 lines of code. That includes pretty formatting and whitespace, because what good is code if it isn’t readable? Imagine creating a grid that will handle file imports for you as simple as this:

                    1. Ext.define('ImportApp.view.Main', {

                    2. extend: 'Ext.grid.Panel',

                    3. requires: [

                    4. 'Gearbox.data.file.Store'

                    5. ],

                    6.  

                    7. xtype: 'app-main',

                    8.  

                    9. title: 'Simpsons',

                    10.  

                    11. store: {

                    12. type: 'file',

                    13. storeId: 'Example',

                    14. fields: ['name', 'email', 'phone'],

                    15.  

                    16. proxy: {

                    17. type: 'file'

                    18. }

                    19. },

                    20.  

                    21. columns: [{

                    22. text: 'Name',

                    23. dataIndex: 'name'

                    24. }, {

                    25. text: 'Email',

                    26. dataIndex: 'email',

                    27. flex: 1

                    28. }, {

                    29. text: 'Phone',

                    30. dataIndex: 'phone'

                    31. }],

                    32.  

                    33. tools: [{

                    34. callback: function(grid) {

                    35. var store = grid.getStore();

                    36. store.exportFile(grid.columns, grid.title);

                    37. }

                    38. }],

                    39.  

                    40. afterRender: function() {

                    41. this.getStore().bindDrop(this);

                    42. this.callParent(arguments);

                    43. }

                    44. });

                    Seasoned ExtJS developers will immediately understand and recognize the above code and structure, but please indulge us to elaborate a bit on what is going on. The most important thing to notice is that all file processing takes place client side. This means that concurrent user imports will will not slow each other down. First, a simple grid and store are created with information about what data to expect (31 lines). Then, in the afterRender function, the grid’s store is instructed to listen for files dropped on the grid (4 lines). This can only be done in the afterRender method since we need the actual DOM elements being created already.

                    • afterRender: function() {

                    • this.getStore().bindDrop(this);

                    • this.callParent(arguments);

                    • }

                    Lastly, a simple button is added that will export the data as a file (6 lines). The button just calls the exportFile method on the store which generates an Excel or CSV file. The Export is also created client-side, not a single line of server code needed.

                    • tools: [{

                    • callback: function(grid) {

                    • var store = grid.getStore();

                    • store.exportFile(grid.columns, grid.title);

                    • }

                    • }]

                    The observant reader will have noticed that the above example does not contain any code for mapping the Excel columns to model fields. That’s because (unless you choose to do it manually) that too is handled for you. As long as your column headers and field names are close enough to guess, the Import-Export Gear will automatically map your data to your model. This is more than enough to tackle typos and differences in casing.

                    Tags:

                    Sencha

                    ExtJS

                    Import

                    Export

                    Share on Facebook
                    Share on Twitter
                    Please reload

                    Follow Us

                    September 2017 (1)

                    August 2017 (1)

                    June 2017 (3)

                    May 2017 (1)

                    April 2017 (1)

                    March 2017 (4)

                    February 2017 (1)

                    January 2017 (3)

                    December 2016 (1)

                    October 2016 (2)

                    June 2016 (1)

                    May 2016 (1)

                    August 2014 (2)

                    July 2013 (2)

                    September 2012 (1)

                    July 2012 (1)

                    Please reload

                    Archive
                    • Facebook Basic Square
                    • Twitter Basic Square
                    • Google+ Basic Square