Excel export problem

  1. #1

    Excel export problem

    Hi All,

    For a grid i am trying to use Exporting to excel option. I am pagination the grid.

    As specified in the example of Excel exporting if i don't use that Proxy for the store it will print only the contents in the current page of the grid, and if i use that proxy the pagination will not be visible.

    Can you please tell me if i want use that pagination and well as if i want to print the whole content in that grid (including all pages) what i have to do?


    Thanks in advance

    I
  2. #2

    RE: Excel export problem

    Hi,

    We added new functionality which allows to submit/retrieve data from all pages (if local paging using). The new functionality will be available in 0.8.2 release


    At this moment you can review the following sample
    http://forums.ext.net/showthread.php?postid=17077.aspx
  3. #3

    RE: Excel export problem

    Hi,

    I got the solution in one of the thread in the same forum. I mean now i am able to export all the data... but it also exports the columns which is hidden and the other thing is the column header in the excel will take the dataindex of the column and not the actual header in the grid.

    I dont want to export the column which is hidden and also the column header in the excel should be the same header name which is given to the column in the grid... Can u please tell me how to achieve the same.?


    Thanks in advance
  4. #4

    RE: Excel export problem

    I am doing something similiar and will be exporting to pdf and excel. To achieve what you are asking the following is what I have done:

    in the grid panel toolbar I have

                            <ext:Button ID="Button4" runat="server" Text="To PDF" AutoPostBack="true" 
                                &#111;nclick="ToPDF" Icon="PageWhiteAcrobat" meta:resourcekey="Button4Resource1" >
                                <Listeners>
                                    <Click Handler="retrieveGridFormatInfo(#{GridPanel1}, 'export');" />
                                </Listeners>
                            </ext:Button>
    I pass the grid into the javascript function get the column model object and loop through the columns to get the header, width, etc

    
        var gridObj = eval(grid);
        var columnModel = gridObj.getColumnModel();
    
        // This will be used to create the columns definition
        var arCol = [];
    
        for (var i = 0; i < allColumnCount; i += 1) {
    
            var blnIncludeColumn = true;
             
            if (retrieveFor == 'export') {
                // for export option only get columns that are not hidden and have a data column (to exclude link columns)  
              blnIncludeColumn = (columnModel.isHidden(i) == undefined) &amp;&amp; (columnModel.getDataIndex(i) != undefined);
            }
    
            if (blnIncludeColumn == true) {
                var oCol = {};
                oCol["index"] = i;
                oCol["name"] = columnModel.getDataIndex(i);
                oCol["header"] = columnModel.getColumnHeader(i);
                oCol["width"] = columnModel.getColumnWidth(i);
                oCol["isHidden"] = columnModel.isHidden(i);
    
                arCol.push(oCol);
            }
        }
    
        // JSON encode the column array and place in the hidden column object
        GridColumns.setValue(Ext.encode(arCol));
    then in the ToPDF in code behind I deserialize the JSON string to a dictionary and cycle through it to get each column info. Try something similiar to above and put a break point at the for loop and then look at your locals window. You will be able to see all of the properties/ methods / events available client side for the grid.

    The piece I am stuck on is that I want to get the renderer so that I can format the export output the same as the grid column. When I try

    columnModel.getRenderer(i).Fn
    columnModel.getRenderer(i).Format
    columnModel.getRenderer(i).FormatArgs
    columnModel.getRenderer(i).Handler
    they all return as undefined even if the <renderer> has been set. Any suggestions on that?

Similar Threads

  1. Export to Excel
    By JonC in forum 1.x Help
    Replies: 9
    Last Post: Nov 13, 2012, 4:59 AM
  2. Export to Excel
    By ChrisO in forum 2.x Help
    Replies: 1
    Last Post: Jun 21, 2012, 4:08 PM
  3. Problem with MVC and Export to Excel
    By reyonlines in forum 1.x Help
    Replies: 3
    Last Post: Apr 03, 2012, 10:44 AM
  4. problem in export to excel
    By danilo in forum 1.x Help
    Replies: 0
    Last Post: Nov 16, 2010, 3:07 PM
  5. Replies: 3
    Last Post: Mar 16, 2010, 1:50 PM

Posting Permissions