1. #211
    Sencha User
    Join Date
    May 2009
    Posts
    4
    Vote Rating
    0
    pardha is on a distinguished road

      0  

    Default Excel Export is not working

    Excel Export is not working


    Hi, Can someone cleanup and show an working example of Excel export without flash.. I have tried of example given in this thread but no luck. I keep getting one another error.

  2. #212
    Sencha User
    Join Date
    Dec 2011
    Posts
    2
    Vote Rating
    0
    a_kanin is on a distinguished road

      0  

    Default Export Complete Store To Excel

    Export Complete Store To Excel


    Hi Wisnia, first of all its amazing all your work. I want to congratulate you for all this.

    I already read de 22 pages of the forum. I was struggling to get the example you gave working, but i managed to do it.

    Now i tried to integrate it to my app and i want to export a complete store, and i am struggilng with it.
    For example i use this:

    Ext.define('SomeGrid', {
    extend: 'Ext.grid.Panel',
    uses: [
    'Ext.ux.exporter.Exporter'
    ],

    initComponent: function() {
    this.dockedItems = [{
    xtype: 'toolbar',
    dock: 'top',
    items: [{
    xtype: 'exporterbutton'
    }]
    }]
    this.callParent(arguments);
    }
    })

    with that ext.define in any you put 'someGrid' and automatically brings the download button and detects store and columns.
    but it sends only the records that seens in the page.
    and to send the full sotre I believe that you need a different method ... or i dont know what am doing wrong.

    Regards.

  3. #213
    Sencha User
    Join Date
    Nov 2011
    Posts
    1
    Vote Rating
    2
    Ecthelion is on a distinguished road

      2  

    Default


    rdominelli's Style.js worked for me, too but the template should be more like this in my opinion:


    Code:
    tpl: new Ext.XTemplate(
        '<tpl if="parentStyle.length == 0">',
          '<ss:Style ss:ID="{id}">',
        '</tpl>',
        '<tpl if="parentStyle.length != 0">',
          '<ss:Style ss:ID="{id}" ss:Parent="{parentStyle}">',
        '</tpl>',
        '<tpl for="attributes">',
          '<tpl if="children.length == 0">',
            '<ss:{name} {propertiesString} />',
          '</tpl>',
          '<tpl if="children.length &gt; 0">',
            '<ss:{name} {propertiesString}>',
              '<tpl for="children">',
                '<ss:{name} {propertiesString} />',
              '</tpl>',
            '</ss:{name}>',
          '</tpl>',
        '</tpl>',
        '</ss:Style>'
      )

    &gt; is used instead of '>' and that also prevents the unwanted '0">' characters. The excel warning is still there, though.


    Code:
          '<tpl if="children.length == 0">',
            '<ss:{name} {propertiesString} />',
          '</tpl>',

    This part reduces the file size as it closes the tags without an end tag, so it's better we leave it there.

  4. #214
    Sencha User
    Join Date
    Aug 2012
    Posts
    91
    Vote Rating
    0
    alex9311 is on a distinguished road

      0  

    Default


    Hey all,

    I would really like to get this working for my grid project but I'm having a lot of trouble. I have been scouring the internet for a couple days and havn'y found anything very helpful in this topic. Even trying to set the loader is crashing my page. I'm using MVC architechture.

    Where should I be setting the loader? In the grid view file or in the top app.js file? Are either of the commented out sections in my grid code the right way to create a print button?

    Here is the code for my List.js (my grid)

    Code:
    Ext.Loader.setConfig({enabled: true});
    Ext.Loader.setPath('Ext.ux', '/var/wwww/application/ux');
    Ext.define('AM.view.user.List' , {
            extend: 'Ext.grid.Panel',
            alias: 'widget.userlist',
            store: 'Users',
            uses: [
                    'Ext.ux.exporter.Exporter'
            ],
            dockedItems: [{
                    xtype: 'toolbar',
                    dock: 'bottom',
                    layout:{
                            pack: 'center'
                    },
                    items: [
                    { 
                            xtype: 'exporterbutton'
                    }
    //                      new Ext.ux.Exporter.Button({
    //                      component: this,
    //                      text     : "Download as .xls"
    //                      })
                    ]
            }],
            initComponent: function() {
                    this.columns=[
                            {header: 'First Name', dataIndex: 'FirstName', width: 75},
                            {header: 'Last Name', dataIndex: 'Last',  width: 75},
                            {header: 'Perm',  dataIndex: 'Perm',     width: 60},
                            {header: 'PreReq', dataIndex: 'PreReq', width: 50,
    
    
                    ];
                    this.callParent(arguments);
            }
    });
    And here is my index.php

    Code:
    <html>
    <head>
            <title>Waitlist</title>
            <link rel="stylesheet" type="text/css" href="ext/resources/css/ext-all.css">
            <script type="text/javascript" src="ext/ext-debug.js"></script>
            <script type="text/javascript" src="app.js"></script>
            <script type="text/javascript" src="ux/exporter/Exporter.js">
    </head>
    <body></body>
    </html>
    Any advice or tips are much appreciated!!

  5. #215
    Sencha User
    Join Date
    Jun 2012
    Posts
    35
    Vote Rating
    1
    Oxii is on a distinguished road

      1  

    Default


    Quote Originally Posted by pardha View Post
    Hi, Can someone cleanup and show an working example of Excel export without flash.. I have tried of example given in this thread but no luck. I keep getting one another error.
    Yes, pleeeease .. we really need someone to do that

  6. #216
    Sencha User
    Join Date
    Apr 2012
    Posts
    9
    Vote Rating
    2
    pksiv is on a distinguished road

      0  

    Default


    Quote Originally Posted by arpeggian View Post
    Attachment 37715

    Now, i get this error when i open the file downloaded.. help me please
    Getting this same problem.

  7. #217
    Ext JS Premium Member
    Join Date
    Apr 2010
    Posts
    102
    Vote Rating
    0
    scaddenp is on a distinguished road

      0  

    Default Non flash version

    Non flash version


    I too browsed this thread looking for a way to use a non-flash download. It turns out that the core of Ext.ux.exporter is actually just responsible for extracting the data from a grid / store in the correct format. This data is then being passed to Downloadify for presentation to the user.

    From memory, it is not easy to directly download data from the client-side (although I may be wrong). However, it is quite easy to initiate from the server-side by setting the src of a hidden iframe to point to a jsp (I presume other server-side languages will work just as well) that initiates a download with the correct response headers and output stream.

    Therefore, I have now created a version of Ext.ux.exporter which will safely initiate a download using this server-side code. Check out https://github.com/stormtek/Ext.ux.Exporter for the latest version. This has been tested in Chrome, Firefox, and IE9, and it should work in older browser as well. Also, I have added an example of this being used (which will be great news for many people).

  8. #218
    Sencha User
    Join Date
    Oct 2012
    Posts
    4
    Vote Rating
    0
    this-is-sparta is on a distinguished road

      0  

    Default


    rdominelli,
    Although excel opens it, the file exported using your version of Style.js is stiil invalid xml (one may encounter unnecessary 0">)
    Actually threr is a simple bug in Style.js: it should be &gt; instead of > in this line:
    '<tpl if="children.length > 0">',
    Attached Files

  9. #219
    Sencha User talha06's Avatar
    Join Date
    Jul 2009
    Location
    Turkey
    Posts
    303
    Vote Rating
    0
    talha06 is on a distinguished road

      0  

    Default


    I have just clone the source from github and applied to one of my grids : Getting an error like this with Ext JS 4.1.1.a on Ubuntu 64-bit while trying to open newly created Excel file:
    Code:
    General Error
    General Input/Output Error
    "People will never forget how you made them feel."
    linkedin.com/in/talhakabakus

  10. #220
    Ext JS Premium Member
    Join Date
    Sep 2008
    Posts
    2
    Vote Rating
    0
    terjeio is on a distinguished road

      0  

    Default


    Here is some changes to the CSV-formatter, now quotes strings and escapes double quotes in strings, exports dates in ISO-format. It could be extended by setting ";" as default separator to avoid problems in locales using comma as decimal point.

    Code:
    //**
     * @class Ext.ux.Exporter.CSVFormatter
     * @extends Ext.ux.Exporter.Formatter
     * Specialised Format class for outputting .csv files
     */
    Ext.define("Ext.ux.exporter.csvFormatter.CsvFormatter", {
        extend: "Ext.ux.exporter.Formatter",
        contentType: 'data:text/csv;base64,',
        separator: ",",
        extension: "csv",
    
        format: function(store, config) {
            this.columns = config.columns || (store.fields ? store.fields.items : store.model.prototype.fields.items);
            return this.getHeaders() + "\n" + this.getRows(store);
        },
        getHeaders: function() {
            var columns = [], title;
            Ext.each(this.columns, function(col) {
              var title;
              if (col.text != undefined) {
                title = col.text;
              } else if(col.name) {
                title = col.name.replace(/_/g, " ");
                title = Ext.String.capitalize(title);
              }
    
              columns.push(title);
            }, this);
    
            return columns.join(this.separator);
        },
        getRows: function(store) {
            var rows = [];
            store.each(function(record, index) {
              rows.push(this.geCell(record, index));
            }, this);
    
            return rows.join("\n");
        },
        geCell: function(record) {
            var cells = [];
            Ext.each(this.columns, function(col) {
                var name = col.name || col.dataIndex;
                if(name) {
                    var value;
                    if (Ext.isFunction(col.renderer) && !col.xtype == 'datecolumn') {
                      value = col.renderer(record.get(name), null, record);
                    } else {
                      value = record.get(name);
                    }
                    cells.push(Ext.isDate(value) ? (value ? Ext.Date.format(value, 'Y-m-d') : '') : (typeof(value) == "string" ? '"' + value.replace(/"/g, '""') + '"' : value));
    
    
                }
            }, this);
    
            return cells.join(this.separator);
        }
    });
    Last edited by terjeio; 17 Oct 2012 at 7:23 AM. Reason: Use Ext.Date.format for ISO-formatting

Thread Participants: 115

  1. dawesi (1 Post)
  2. feiji1983 (1 Post)
  3. isaac (1 Post)
  4. radtad (4 Posts)
  5. austin1030 (1 Post)
  6. pavanextjs (5 Posts)
  7. aragm (1 Post)
  8. terjeio (1 Post)
  9. il Sergio (2 Posts)
  10. edspencer (1 Post)
  11. nitingautam (2 Posts)
  12. edykstra (3 Posts)
  13. kalchas (4 Posts)
  14. pardha (1 Post)
  15. shelly (1 Post)
  16. talha06 (3 Posts)
  17. vaucer (1 Post)
  18. SMMJ_Dev (7 Posts)
  19. Ekambos (1 Post)
  20. vispiron (1 Post)
  21. sdruckerfig (4 Posts)
  22. jwcraig (1 Post)
  23. dbrin (1 Post)
  24. scaddenp (2 Posts)
  25. grisevich (1 Post)
  26. semialcruz (3 Posts)
  27. krishnarn1 (1 Post)
  28. mikih (1 Post)
  29. Teemac (3 Posts)
  30. jpcoppol (1 Post)
  31. ssuarez (4 Posts)
  32. trinitrotoluen (1 Post)
  33. aladdina (1 Post)
  34. Mental (3 Posts)
  35. nuskin (5 Posts)
  36. droessner (5 Posts)
  37. HIG (1 Post)
  38. jjerome (4 Posts)
  39. bee (2 Posts)
  40. RAD001 (8 Posts)
  41. RNL (1 Post)
  42. shawon (4 Posts)
  43. parkcity (4 Posts)
  44. carlosgoias (1 Post)
  45. Ewoq (7 Posts)
  46. skotamreddy (1 Post)
  47. another_i (5 Posts)
  48. neerajbherwal (1 Post)
  49. nimda13 (2 Posts)
  50. acteon (2 Posts)
  51. ma1986 (2 Posts)
  52. pierrocknroll (1 Post)
  53. Aranair (7 Posts)
  54. clarkbanks (1 Post)
  55. linyajun (1 Post)
  56. delusion (2 Posts)
  57. Jay Tanwar (2 Posts)
  58. supermarcos (6 Posts)
  59. mmuzamil (1 Post)
  60. amishra06 (1 Post)
  61. hundare (1 Post)
  62. Ecthelion (1 Post)
  63. balajivaikar (2 Posts)
  64. jarobi (1 Post)
  65. ferchotipin (2 Posts)
  66. sebas2515 (3 Posts)
  67. arpeggian (3 Posts)
  68. a_kanin (1 Post)
  69. MeDigital (1 Post)
  70. Vasanthoo7 (3 Posts)
  71. jeora (1 Post)
  72. BlackLine (1 Post)
  73. mrhomer (7 Posts)
  74. KostasP (2 Posts)
  75. rdominelli (4 Posts)
  76. pksiv (1 Post)
  77. yoisen (2 Posts)
  78. opms (1 Post)
  79. Oxii (1 Post)
  80. sarz (6 Posts)
  81. gabsoftware (3 Posts)
  82. 9josh (1 Post)
  83. ananthk (2 Posts)
  84. psnprasad (1 Post)
  85. alex9311 (2 Posts)
  86. felix822 (2 Posts)
  87. mpasacrita@escholar.com (1 Post)
  88. Garry Hawkins (1 Post)
  89. jesus.balles (1 Post)
  90. chandrima31 (1 Post)
  91. this-is-sparta (1 Post)
  92. vitalz (7 Posts)
  93. Sheng_Yunzhou (2 Posts)
  94. xdengli (1 Post)
  95. sgscontact (1 Post)
  96. nitingogia@gmail.com (1 Post)
  97. Swetosuvro (1 Post)
  98. sudrak (1 Post)
  99. cdmein (1 Post)
  100. code4jhon (1 Post)
  101. felixfang (2 Posts)
  102. jayasingh1802 (2 Posts)
  103. abdul haq (3 Posts)
  104. luatbravo (1 Post)
  105. gilmaredo@gmail.com (1 Post)
  106. ricardo.lourival (1 Post)
  107. Sundarganesh Ramar (1 Post)
  108. madhavan281981 (1 Post)
  109. suvo (3 Posts)
  110. shankar8rajah1 (1 Post)
  111. benny_GI (1 Post)
  112. cojocarutudor (1 Post)
  113. arnoldvillasanta (4 Posts)
  114. tajashwin (1 Post)
  115. mangeshppatil (2 Posts)