Page 2 of 30 FirstFirst 123412 ... LastLast
Results 11 to 20 of 296

Thread: GridPanel directly to Excel.

  1. #11
    Ext JS Premium Member Foggy's Avatar
    Join Date
    Apr 2007
    Location
    Switzerland
    Posts
    477
    Vote Rating
    0
      0  

    Default

    Really nice extension, thanks for that animal.
    Maybe a better solution would be to send the Excel xml to a backend and create a file? In this case you are not rely on any browser stuff...

  2. #12
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,615
    Vote Rating
    54
      0  

    Default

    Well, if there's going to be a backend involved, it's better that that should just produce the XML itself. It has all the data, so it should just be able to process it into a valid XML spreadsheet. In our app, we have an Excel export button, but it just requests a document to be generated from the server, it does not send any info up.

  3. #13
    Ext JS Premium Member Foggy's Avatar
    Join Date
    Apr 2007
    Location
    Switzerland
    Posts
    477
    Vote Rating
    0
      0  

    Default

    it's better that that should just produce the XML itself. It has all the data, so it should just be able to process it into a valid XML spreadsheet.
    Of course, you are right

  4. #14
    Sencha User galdaka's Avatar
    Join Date
    Mar 2007
    Location
    Spain
    Posts
    1,166
    Vote Rating
    0
      0  

    Default

    Works fine!!

    Good work!!

  5. #15
    Ext User
    Join Date
    Mar 2007
    Posts
    10
    Vote Rating
    0
      0  

    Default

    I found some bug with a grid containing hidden columns, there is a mismatch between excel cells type and values when you have different types of data

    when retrieving the cell types I added a specific var for incrementation:

    Code:
    var k=0;
    for (var j = 0; j < cm.getColumnCount(); j++) {
    	if (includeHidden || !cm.isHidden(j)) {
    		var v = r[cm.getDataIndex(j)];
    		t += '<ss:Cell ss:StyleID="' + cellClass + cellTypeClass[k] + '"><ss:Data ss:Type="' + cellType[k] + '">';
    		if (cellType[k] == 'DateTime') {
    			t += v.format('Y-m-d');
    		} else {
    			t += v;
    		}
    		t +='</ss:Data></ss:Cell>';
    		k++;
    	}
    }
    It works for me with this update

    One more thing : why don't you use a basic toolbar button for exporting, which will automatically refresh the data url like this :

    Code:
    bbar: new Ext.Toolbar({
            	buttons: [{
        			id: 'grid-excel-button',
        			text: 'Excel',
    			handler: function(){
    				document.location='data:application/vnd.ms-excel;base64,' +Base64.encode(grid.getExcelXml());
    			}
        		}]
    	})

  6. #16
    Sencha User
    Join Date
    Aug 2007
    Location
    Munich, Germany
    Posts
    135
    Vote Rating
    2
      0  

    Default

    And it will only works on ie8+ ? @Galdaka: you tested it on IE6?

  7. #17
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,615
    Vote Rating
    54
      0  

    Default

    Quote Originally Posted by ghyster View Post
    I found some bug with a grid containing hidden columns, there is a mismatch between excel cells type and values when you have different types of data

    when retrieving the cell types I added a specific var for incrementation:

    Code:
    var k=0;
    for (var j = 0; j < cm.getColumnCount(); j++) {
    	if (includeHidden || !cm.isHidden(j)) {
    		var v = r[cm.getDataIndex(j)];
    		t += '<ss:Cell ss:StyleID="' + cellClass + cellTypeClass[k] + '"><ss:Data ss:Type="' + cellType[k] + '">';
    		if (cellType[k] == 'DateTime') {
    			t += v.format('Y-m-d');
    		} else {
    			t += v;
    		}
    		t +='</ss:Data></ss:Cell>';
    		k++;
    	}
    }
    It works for me with this update

    One more thing : why don't you use a basic toolbar button for exporting, which will automatically refresh the data url like this :

    Code:
    bbar: new Ext.Toolbar({
            	buttons: [{
        			id: 'grid-excel-button',
        			text: 'Excel',
    			handler: function(){
    				document.location='data:application/vnd.ms-excel;base64,' +Base64.encode(grid.getExcelXml());
    			}
        		}]
    	})
    OK, thanks for this info. Can you bump this thread tomorrow, and I'll try ity out with hidden columns and fix it.

    Yes, I was thinking of different ways to make the download smoother, if that works in all cases, I'll change the demo to use that.

  8. #18
    Ext User
    Join Date
    Apr 2008
    Posts
    3
    Vote Rating
    0
      0  

    Default server side excel

    Great plugin Animal, I have a server side paging in my grid and I want to be able to export to excel , doing it on the server side is fine with me, but how do I bring up a file download dialog box once the data is back from the server? I am quite new to Ext and this simple thing is taking me a long time...

    Also, in my toolbar I have a button "export to Excel" , and I want it to export only the data on the current page, not the whole store data, so how do I pass along the current data to the server side to generate a XML? any ideas ?

  9. #19
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,615
    Vote Rating
    54
      0  

    Default

    If you just want the current page, then you can do it on the client.

    If you are doing it on the server, that's totally up to you.

  10. #20
    Ext JS Premium Member
    Join Date
    Dec 2007
    Posts
    213
    Vote Rating
    0
      0  

    Default

    Hi,

    I'm testing this but getting an error message:

    PHP Code:
    unterminated string constant 
    Any help? please!

Page 2 of 30 FirstFirst 123412 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •