1. #201
    Sencha User
    Join Date
    Jul 2011
    Location
    Russia
    Posts
    41
    Vote Rating
    3
    another_i is on a distinguished road

      0  

    Default


    @gabsoftware, ok.
    What structure is in your grid? What columns is in it?

    And you can insert debugger here and look in firebug or chrome debugger tool your xml, in variable returner, that will be encoded by Base64 in next step:
    Code:
    //...
    returner += resultstring;
    debugger; 
    window.location.href = window.location.href = 'data:application/vnd.ms-excel;base64,' +Base64.encode(returner);
    //...

  2. #202
    Sencha User
    Join Date
    Jul 2011
    Location
    Russia
    Posts
    41
    Vote Rating
    3
    another_i is on a distinguished road

      0  

    Default


    CSV is great format, yes. =)

  3. #203
    Sencha User
    Join Date
    Nov 2011
    Posts
    27
    Vote Rating
    -1
    ferchotipin is an unknown quantity at this point

      0  

    Default


    @gabsoftware

    I tried and it is working in Chrome in a test version I did:

    Code:
    Ext.define('SomeGrid', {
        extend: 'Ext.grid.Panel',
        uses: ['Ext.ux.exporter.Exporter'],
    
    
        initComponent: function() {
            this.callParent(arguments);
        }
    })
    
    
    Ext.onReady(function() {
    
    
        Ext.create('Ext.data.Store', {
            storeId: 'simpsonsStore',
            fields: ['name', 'email', 'phone'],
            data: {
                'items': [{
                    "name": "Lisa",
                    "email": "lisa@simpsons.com",
                    "phone": "555-111-1224"
                }, {
                    "name": "Bart",
                    "email": "bart@simpsons.com",
                    "phone": "555--222-1234"
                }, {
                    "name": "Homer",
                    "email": "home@simpsons.com",
                    "phone": "555-222-1244"
                }, {
                    "name": "Marge",
                    "email": "marge@simpsons.com",
                    "phone": "555-222-1254"
                }]
            },
            proxy: {
                type: 'memory',
                reader: {
                    type: 'json',
                    root: 'items'
                }
            }
        });
    
    
        Ext.create('SomeGrid', {
            title: 'Simpsons',
            store: Ext.data.StoreManager.lookup('simpsonsStore'),
            tbar: [{
                xtype: 'button',
                handler: function(btn, e, options) {
                    // Base64 encode / decode http://www.webtoolkit.info/
                    var Base64 = (
    
    
                    function() {
                        // private property
                        var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
    
    
    
    
                        // private method for UTF-8 encoding
    
    
                        function utf8Encode(string) {
                            string = string.replace(/\r\n/g, "\n");
                            var utftext = "";
                            for (var n = 0; n < string.length; n++) {
                                var c = string.charCodeAt(n);
                                if (c < 128) {
                                    utftext += String.fromCharCode(c);
                                } else if ((c > 127) && (c < 2048)) {
                                    utftext += String.fromCharCode((c >> 6) | 192);
                                    utftext += String.fromCharCode((c & 63) | 128);
                                } else {
                                    utftext += String.fromCharCode((c >> 12) | 224);
                                    utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                                    utftext += String.fromCharCode((c & 63) | 128);
                                }
                            }
                            return utftext;
                        }
    
    
    
    
                        // public method for encoding
                        return {
                            encode: (typeof btoa == 'function') ?
                            function(input) {
                                return btoa(input);
                            } : function(input) {
                                var output = "";
                                var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
                                var i = 0;
                                input = utf8Encode(input);
                                while (i < input.length) {
                                    chr1 = input.charCodeAt(i++);
                                    chr2 = input.charCodeAt(i++);
                                    chr3 = input.charCodeAt(i++);
                                    enc1 = chr1 >> 2;
                                    enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
                                    enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
                                    enc4 = chr3 & 63;
                                    if (isNaN(chr2)) {
                                        enc3 = enc4 = 64;
                                    } else if (isNaN(chr3)) {
                                        enc4 = 64;
                                    }
                                    output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4);
                                }
                                return output;
                            }
                        };
                    })();
    
    
    
    
                    var grid = btn.up("gridpanel"),
                        counter = 0;
    
    
                    var columns = Ext.Array.filter(
                    grid.columns, function(col) {
                        return !col.hidden; // && (!col.xtype || col.xtype != "actioncolumn");
                    });
    
    
                    var sm = grid.getSelectionModel().getSelection();
                    var title = grid.title;
    
    
                    var returner = "";
    
    
                    var data = [];
                    for (var i = 0; i < grid.store.data.items.length; i++) {
                        data[i] = grid.store.data.items[i].data;
                    }
                    counter = data.length;
    
    
                    //build the header line
                    for (var i = 0; i < columns.length; i++) {
                        if (i > 0) {
                            returner += ",";
                        }
                        returner += columns[i].dataIndex;
                    }
    
    
    
    
                    var value;
    
    
                    //For each line
                    for (var i = 0; i < data.length; i++) {
                        //begins a new line
                        returner += "\n";
    
    
                        //builds a line
                        for (var j = 0; j < columns.length; j++) {
                            if (j > 0) {
                                returner += ",";
                            }
                            value = data[i][columns[j].dataIndex];
                            if (value === null) {
                                value = "";
                            }
                            returner += value;
                        }
                    }
    
    
                    //send the file
                    downloadDataURI({
                        filename: "export.csv",
                        data: "data:text/csv;base64," + Base64.encode(returner)
                    });
    
    
                    //display how many exported rows
                    Ext.MessageBox.show({
                        title: 'Export',
                        msg: counter + ' lignes ont été exportées.',
                        buttons: Ext.MessageBox.OK
                    });
                }
            }],
            columns: [{
                header: 'Name',
                dataIndex: 'name'
            }, {
                header: 'Email',
                dataIndex: 'email',
                flex: 1
            }, {
                header: 'Phone',
                dataIndex: 'phone'
            }],
            height: 200,
            width: 400,
            renderTo: Ext.getBody()
        });
    });
    
    
    var downloadDataURI = function(options) {
            if (!options) {
                return;
            }
            $.isPlainObject(options) || (options = {
                data: options
            });
            if (!$.browser.webkit) {
                location.href = options.data;
            }
            options.filename || (options.filename = "download." + options.data.split(",")[0].split(";")[0].substring(5).split("/")[1]);
            options.url || (options.url = "http://download-data-uri.appspot.com/");
            $('<form method="post" action="' + options.url + '" style="display:none"><input type="hidden" name="filename" value="' + options.filename + '"/><input type="hidden" name="data" value="' + options.data + '"/></form>').submit().remove();
    
        }
    but when I try it in Firefox it downloads a .part file with a random characters name, I open it, it has the information, and in IE it doesn't do anything it send me to this address:

    Code:
    data:text/csv;base64,bmFtZSxlbWFpbCxwaG9uZQpMaXNhLGxpc2FAc2ltcHNvbnMuY29tLDU1NS0xMTEtMTIyNApCYXJ0LGJhcnRAc2ltcHNvbnMuY29tLDU1NS0tMjIyLTEyMzQKSG9tZXIsaG9tZUBzaW1wc29ucy5jb20sNTU1LTIyMi0xMjQ0Ck1hcmdlLG1hcmdlQHNpbXBzb25zLmNvbSw1NTUtMjIyLTEyNTQ=


    Now when I try it in my server version in chrome it send me to this address:

    http://download-data-uri.appspot.com/

    in firefox does the same as the local it downloads a .part file with the info inside.

    in IE does the same as the local.


    Any thoughts!...thx

  4. #204
    Ext JS Premium Member
    Join Date
    Jan 2012
    Posts
    3
    Vote Rating
    0
    MeDigital is on a distinguished road

      0  

    Default more bugs

    more bugs


    It does not seems to work on firefox...

    seems to work only at Chrome and IE

  5. #205
    Sencha User arpeggian's Avatar
    Join Date
    Dec 2011
    Posts
    21
    Vote Rating
    1
    arpeggian is on a distinguished road

      0  

    Default


    Hi, i get a blank toolbar.. whats wrong with my code?

    index.html
    Code:
    ...
    <script type="text/javascript" src="extjs/src/ux/exporter/downloadify.min.js"></script>
    <script type="text/javascript" src="extjs/src/ux/exporter/swfobject.js"></script>
    ...
    app.js
    Code:
    ....
    Ext.require([
    			'Ext.tree.Panel',
    			'Ext.data.TreeStore',
    			'Ext.tab.Panel',
    			'Ext.Viewport',
    			'Ext.ux.exporter.Exporter'
    			]);
    .....
    in my grid
    Code:
    ...
    tbar : [
                {
                  xtype: 'exporterbutton'
                }
        ],
    ...
    If i need include expressinstall? for flash? or anything wrong with my code?
    please help me... thanks a lot before and sorry for my poor english.

    regards.

  6. #206
    Sencha User arpeggian's Avatar
    Join Date
    Dec 2011
    Posts
    21
    Vote Rating
    1
    arpeggian is on a distinguished road

      0  

    Default


    Opps, sorry.. i can figure out.. my problem is path of swf and the image. but now, when i click the download button, nothing happened... i also check it with firebug, but nothing to display

    Quote Originally Posted by arpeggian View Post
    Hi, i get a blank toolbar.. whats wrong with my code?

    index.html
    Code:
    ...
    <script type="text/javascript" src="extjs/src/ux/exporter/downloadify.min.js"></script>
    <script type="text/javascript" src="extjs/src/ux/exporter/swfobject.js"></script>
    ...
    app.js
    Code:
    ....
    Ext.require([
                'Ext.tree.Panel',
                'Ext.data.TreeStore',
                'Ext.tab.Panel',
                'Ext.Viewport',
                'Ext.ux.exporter.Exporter'
                ]);
    .....
    in my grid
    Code:
    ...
    tbar : [
                {
                  xtype: 'exporterbutton'
                }
        ],
    ...
    If i need include expressinstall? for flash? or anything wrong with my code?
    please help me... thanks a lot before and sorry for my poor english.

    regards.

  7. #207
    Sencha User arpeggian's Avatar
    Join Date
    Dec 2011
    Posts
    21
    Vote Rating
    1
    arpeggian is on a distinguished road

      1  

    Default Problem

    Problem


    error xls.JPG

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

  8. #208
    Sencha User
    Join Date
    Mar 2012
    Posts
    22
    Vote Rating
    1
    KostasP is on a distinguished road

      0  

    Default


    I downloaded the code from here https://github.com/iwiznia/Ext.ux.Exporter

    It throws an error Uncaught ReferenceError: Downloadify is not defined

    What should I do to make it working? There are 16 pages of comments so any quickhint will be appreciated...

  9. #209
    Sencha User
    Join Date
    Mar 2012
    Posts
    22
    Vote Rating
    1
    KostasP is on a distinguished road

      1  

    Default


    I included Downloadify code from here https://github.com/dcneiner/Downloadify

    a
    nd i get the same error with the Style described 2 posts above...

  10. #210
    Sencha User
    Join Date
    Jul 2011
    Location
    Rio de Janeiro
    Posts
    31
    Vote Rating
    0
    carlosgoias is on a distinguished road

      0  

    Default


    This post is some how frustrating!

    But, some how I made It work for OpenOffice... for Excel still file corrupted

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)