1. #121
    Ext User zhw511006's Avatar
    Join Date
    Oct 2008
    Posts
    39
    Vote Rating
    0
    zhw511006 is on a distinguished road

      0  

    Default


    Thank you for sharing your code!

    But Error ! IE7:
    The data area passed to a system call is too small.


  2. #122
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default


    From post #1 one of this thread (emphasis added):
    Quote Originally Posted by Animal View Post
    This needs a browser that supports data URLs. FF, Opera and IE8 will support this.
    .

  3. #123
    Ext User
    Join Date
    Sep 2008
    Posts
    6
    Vote Rating
    0
    snoir is on a distinguished road

      0  

    Exclamation


    Quote Originally Posted by aproust94 View Post
    Your PHP code should be like this one:

    PHP Code:
    header("Pragma: public");
    header("Expires: 0"); // set expiration time
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Content-Type: application/force-download");
    header('Content-type: application/vnd.ms-excel');
    header("Content-Disposition:attachment;filename=export");
    echo 
    $_REQUEST['ex']; 
    i don't understand php code,i want jsp code

  4. #124
    Ext User jmcneese's Avatar
    Join Date
    Feb 2008
    Posts
    25
    Vote Rating
    0
    jmcneese is on a distinguished road

      0  

    Default


    Quote Originally Posted by snoir View Post
    i don't understand php code,i want jsp code
    dude. are you saying you use JSP and don't know enough to translate the above PHP code (which is about as simple as it gets) into JSP?

    this forum isn't a soup kitchen. go hit up the php website (maybe http://www.php.net/echo and http://www.php.net/header will help) and figure it out.

  5. #125
    Ext User
    Join Date
    Sep 2008
    Posts
    6
    Vote Rating
    0
    snoir is on a distinguished road

      0  

    Exclamation


    this is my js code:
    Code:
    Ext.Ajax.request({
                      url: '../../exportexcel.jsp',
                      method: 'POST',
                      form: Ext.fly('frmDummy'),
                      callback: function(o, s, r) {
                          //alert(r.responseText);
                      },
                      isUpload: true,
                      params: {exportContent:vExportContent}
                   })
    this is jsp code:
    HTML Code:
    <%
     response.setHeader("Pragma","public");
     response.setHeader("Expires","0");
     response.setHeader("Cache-Control","must-revalidate, post-check=0, pre-check=0");
     response.setHeader("Content-Type","application/force-download");
     response.setHeader("Content-Type","application/vnd.ms-excel");
     response.setHeader("Content-Disposition","attachment;filename=export");
     
     out.print(request.getParameter("exportContent"));
      %>
    i can't get "exportContent" in jsp.........
    i open the excel file,it's null....but in function callback can show the 'exportContent''s value......


    when i delete 'form: Ext.fly('frmDummy')' ,jsp can get the params.......
    How to resolve this issue???

  6. #126
    Sencha User emredagli's Avatar
    Join Date
    Jun 2008
    Posts
    301
    Vote Rating
    2
    emredagli is on a distinguished road

      0  

    Default Grid directly to excel in IE7.0 and setting file names

    Grid directly to excel in IE7.0 and setting file names


    Hii,
    I found a way to save as different filename and also working in IE 7.0 by using .NET framework in server side.
    .js code:
    Code:
    function post_to_url(path, params, method) {
        method = method || "post"; 
    
        var form = document.createElement("form");
        form.setAttribute("method", method);
        form.setAttribute("action", path);
    
        for(var i=0; i<params.length; i++) {
            var hiddenField = document.createElement("input");
            hiddenField.setAttribute("type", "hidden");
            hiddenField.setAttribute("name", params[i].name);
            hiddenField.setAttribute("value", params[i].value);
    
            form.appendChild(hiddenField);
        }
    
        document.body.appendChild(form);   
        form.submit();
    }
    
    function exportExcell() {
    
        var dataURL = 'CommonPages/ExportToExcelType1.aspx';
    
        params =[{
            name: 'Data',
            value: resultGrid.getExcelXml()  // Mr. Animal's part...
        },{
            name: 'FileName',
            value: 'File1.xls'
        }];
        
        post_to_url(dataURL, params, 'post');
    }
    CommonPages/ExportToExcelType1.aspx.cs code is:

    Code:
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Clear();
            Response.Buffer = true;
            Response.ContentType = "application/vnd.ms-excel";
            Response.AddHeader("Content-Disposition", "attachment;filename=\"" + Request.Params["FileName"].ToString() + "\"");
            Response.Charset = "";
            this.EnableViewState = false;
                
            System.IO.StringWriter SW = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter HTW = new System.Web.UI.HtmlTextWriter(SW);
            HTW.WriteLine(Request.Params["Data"]);
    
            Response.Write(SW.ToString());
            Response.End();
    
        }
    And do not forget to put ValidateRequest="false" in the top of the ExportToExcelType1.aspx file like:
    Code:
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="ExportToExcelType1.aspx.cs" Inherits="CommonPages_ExportToExcelType1" ValidateRequest="false"%>
    In this solution there may be unnecessary parts...
    But it works nicelly.
    I hope it helps you... Good luck...

  7. #127
    Ext User
    Join Date
    Sep 2008
    Posts
    6
    Vote Rating
    0
    snoir is on a distinguished road

      0  

    Default


    Quote Originally Posted by emredagli View Post
    In this solution there may be unnecessary parts...
    But it works nicelly.
    I hope it helps you... Good luck...
    thx,emredagli.the code is ok.

    my js:
    Code:
    var exportMenu= {
          text: 'ExportToExcel',
          iconCls:'export',
          tooltip:'ExportToExcel',
          handler: function() {
              var vExportContent = grid.getExcelXml();
              if (Ext.isIE6 || Ext.isIE7 || Ext.isSafari || Ext.isSafari2 || Ext.isSafari3) {
                  var dataURL = '../../exportexcel.jsp';
                  params =[{
                       name: 'ex',
                       value: vExportContent 
                  },{
                      name: 'FileName',
                      value: 'excel.xls'
                  }];
                  post_to_url(dataURL, params, 'post');
              } else {
                  document.location = 'data:application/vnd.ms-excel;base64,' + Base64.encode(vExportContent);
              }
             }
      };
     
    function post_to_url(path, params, method) {
         method = method || "post"; 
         var form = document.createElement("form");
         form.setAttribute("method", method);
         form.setAttribute("action", path);
         for(var i=0; i<params.length; i++) {
             var hiddenField = document.createElement("input");
             hiddenField.setAttribute("type", "hidden");
             hiddenField.setAttribute("name", params[i].name);
             hiddenField.setAttribute("value", params[i].value);            
             form.appendChild(hiddenField);
         }   
         document.body.appendChild(form);   
         form.submit();
     }
    my jsp:
    HTML Code:
    <% response.setHeader("Pragma","public");
     response.setHeader("Expires","0");
     response.setHeader("Cache-Control","must-revalidate, post-check=0, pre-check=0");
     response.setHeader("Content-Type","application/force-download");
     response.setHeader("Content-Type","application/vnd.ms-excel");
     response.setHeader("Content-Disposition","attachment;filename="+request.getParameter("FileName"));
     
     out.print(request.getParameter("ex"));
     %>

  8. #128
    Ext User
    Join Date
    Dec 2008
    Posts
    4
    Vote Rating
    0
    vvreddy@12 is on a distinguished road

      0  

    Default export a grid to excel

    export a grid to excel


    Hi snoir,

    I have used the same code given by you but could not get the output.

    I am getting a blank excel sheet.
    please let me know what to do ????

    Thanks,
    Vishnu

  9. #129
    Sencha User emredagli's Avatar
    Join Date
    Jun 2008
    Posts
    301
    Vote Rating
    2
    emredagli is on a distinguished road

      0  

    Default


    Are you sure the excel datas created successfully?

    (By putting break point on Firefox) Check the,
    Code:
    var vExportContent = grid.getExcelXml();
    part.

  10. #130
    Ext User
    Join Date
    Dec 2008
    Posts
    4
    Vote Rating
    0
    vvreddy@12 is on a distinguished road

      0  

    Default export a grid to excel

    export a grid to excel


    Hi Emredagli,

    The excel was blank and didn't get any data. Can you suggest me what was wrong in that piece of code.

    Thanks,
    Vishnu

Thread Participants: 140

  1. alexb (1 Post)
  2. galdaka (3 Posts)
  3. ghyster (1 Post)
  4. Condor (1 Post)
  5. TopKatz (1 Post)
  6. Jul (1 Post)
  7. mystix (3 Posts)
  8. Foggy (2 Posts)
  9. bloon (1 Post)
  10. fshort (1 Post)
  11. antimatter15 (1 Post)
  12. cocinerox (1 Post)
  13. tobiu (1 Post)
  14. ajaxE (2 Posts)
  15. andreyz (1 Post)
  16. devnull (4 Posts)
  17. mjlecomte (4 Posts)
  18. kevinwu8 (1 Post)
  19. rakesh (1 Post)
  20. hendricd (2 Posts)
  21. gelleneu (1 Post)
  22. isaac (1 Post)
  23. huling (1 Post)
  24. ckr (1 Post)
  25. roopa (1 Post)
  26. loveyeah (1 Post)
  27. zhfxu_cs (1 Post)
  28. Mthor (1 Post)
  29. johnlicy (1 Post)
  30. thoreking (2 Posts)
  31. csqjean (1 Post)
  32. mankz (1 Post)
  33. vietschv (1 Post)
  34. verbi (1 Post)
  35. sanjshah (2 Posts)
  36. mask_hot (1 Post)
  37. calavera (1 Post)
  38. vsmike (1 Post)
  39. vizcano (1 Post)
  40. lakehouse (1 Post)
  41. alaska (2 Posts)
  42. radtad (3 Posts)
  43. jmcneese (1 Post)
  44. Rafael (4 Posts)
  45. calvouze (1 Post)
  46. Joyfulbob (1 Post)
  47. angeldimitrov (2 Posts)
  48. Jack_S (2 Posts)
  49. g13013 (2 Posts)
  50. DamienValentine (5 Posts)
  51. Marcelo Delgado (1 Post)
  52. NoahK17 (8 Posts)
  53. anujg (1 Post)
  54. aproust94 (3 Posts)
  55. pokerking400 (1 Post)
  56. Ronhead (1 Post)
  57. krzak (3 Posts)
  58. cvieira (1 Post)
  59. Efex (5 Posts)
  60. gthe (2 Posts)
  61. miihiir (2 Posts)
  62. pops (1 Post)
  63. emredagli (12 Posts)
  64. larsa (2 Posts)
  65. maggiesnyder (3 Posts)
  66. sam.zhang (1 Post)
  67. kristalgic (1 Post)
  68. wiznia (3 Posts)
  69. frpucci (1 Post)
  70. tinakonda (1 Post)
  71. tBSTAR (1 Post)
  72. tdg2008 (1 Post)
  73. iwagon (1 Post)
  74. psarunkumar (1 Post)
  75. kimmking (1 Post)
  76. sKuD24 (1 Post)
  77. MartinL (2 Posts)
  78. BitPoet (2 Posts)
  79. snoir (3 Posts)
  80. naranda (1 Post)
  81. zhw511006 (1 Post)
  82. bobjbain (1 Post)
  83. korto (1 Post)
  84. wp.joju (1 Post)
  85. hastiok (6 Posts)
  86. dtondo (4 Posts)
  87. Dumas (1 Post)
  88. vvreddy@12 (4 Posts)
  89. TheBim (1 Post)
  90. whodat (2 Posts)
  91. Skunkerbr (2 Posts)
  92. stevenhzj (4 Posts)
  93. Naokai (1 Post)
  94. wayned@escc (2 Posts)
  95. MuadDib-DK (1 Post)
  96. jsundquist (1 Post)
  97. hardc0re (2 Posts)
  98. hzwei (4 Posts)
  99. Galileo_Galilei (1 Post)
  100. SantaBarbarian (4 Posts)
  101. stevieke (1 Post)
  102. megmefleg (1 Post)
  103. Boccara Jonathan (1 Post)
  104. Surinder singh (2 Posts)
  105. KrullWarKing (1 Post)
  106. brandnewdrew (1 Post)
  107. MrRoyce (1 Post)
  108. Spongerusher (1 Post)
  109. teraphy (2 Posts)
  110. Pekka Karalahti (3 Posts)
  111. Sergii (1 Post)
  112. Cassio11 (1 Post)
  113. myth (1 Post)
  114. spor (6 Posts)
  115. StagnantIce (2 Posts)
  116. shailendra (2 Posts)
  117. ext_user1 (1 Post)
  118. kenny_mk (1 Post)
  119. mpacheco (1 Post)
  120. Centurus (1 Post)
  121. andyfly (1 Post)
  122. darmandovargas@gmail.com (1 Post)
  123. zjuthhy (3 Posts)
  124. robshim (3 Posts)
  125. Tod (1 Post)
  126. bipen (2 Posts)
  127. alisyah (1 Post)
  128. Monz87 (1 Post)
  129. alssst (1 Post)
  130. aggie (1 Post)
  131. bradelsky (1 Post)
  132. lagrezd (1 Post)
  133. ma1986 (1 Post)
  134. Sabareesh (2 Posts)
  135. top_1 (1 Post)
  136. Vasanthoo7 (1 Post)
  137. garrek99 (2 Posts)
  138. opik (1 Post)
  139. shankar8rajah1 (1 Post)
  140. tdobberphul (4 Posts)