PDA

View Full Version : Download grid data in excel file.



wasima
1 Mar 2012, 10:22 PM
Hi,
I am able to download grid data into excel file by reading data from the store, but is it possible to read data from the grid, i mean when a user changes the contents of the grid from UI and then when i download the contents , the contents are the same as in the store , i want the updated contents from the grid (after user makes some changes like sorting etc)to be downloaded to excel....is there any way to read contents of grid from client side download it to excel file ?

vietits
1 Mar 2012, 11:52 PM
1. Gridpanel displays data in store, it means that to read grid data you should read them in the store attached to that grid.

2. Have a look at this thread for exporting store data to excel format file: Export store to Excel (http://www.sencha.com/forum/showthread.php?136598-Export-store-to-Excel)

wasima
2 Mar 2012, 2:32 AM
Thanks vietits (http://www.sencha.com/forum/member.php?362966-vietits) ,

When a user modifies the contents of the grid like he has sorted a particular column, and if he wants to export , he will still get the contents in the same form/pattern as it is in the store .......i dont want that......i want the excel sheet to contain the updated/modified grid contents...
is it possible to do that ? pls let me know.....:)

vietits
2 Mar 2012, 4:42 AM
When user do the sorting on the grid, store will update to reflect the new sorting.

wasima
2 Mar 2012, 8:00 AM
Thanks vietits, but how do i update the store when changes like sorting are made on grid ?

vietits
2 Mar 2012, 4:20 PM
It will be done automatically by the framwork. In fact, all the sorting will be done with the store first then the result of changing will be shown on the grid.

wasima
4 Mar 2012, 11:12 PM
Which framework are u talking about ? It doesn't happen in my case...the export still has old values.....

vietits
5 Mar 2012, 12:15 AM
I am using Ext 4.0.7.

What do you mean saying that the export has still old values? How do you export your data?

wasima
5 Mar 2012, 12:18 AM
I use same framework.
I have a button which exports/download's grid data in excel form......now the issue is that if i sort the contents from the UI and then click on button it still shows me the unsorted old values in excel file......how do i update my store after changes from the UI?

vietits
5 Mar 2012, 1:03 AM
I don't know how you export data to excel so it's difficult to say why it still contains old values.

About grid sorting

When you do some sorting from the grid UI, the sorting process will occur in the store first:

If you use remote sorting, the store will call <store>.load() to load data from server. It is your server side responsibility to return the sorted data.
If you use local sorting, data in your store will be sorted, so the order of them in store will change to reflect new sorting.
Then the view will be refreshed to reflect the sorted data of store. So, you don't have to do anything to update data from grid to store.

wasima
5 Mar 2012, 2:46 AM
Thanks,
The confusion is happening because , i am using Extjs4 to display data in the grid and java's jxl api to download grid contents...

ok can you give me more idea about how i can update my store when somebody modifies the grid contents from ui?

vietits
5 Mar 2012, 5:12 AM
As I said you don't have to do anything to update store from grid because in fact the grid only shows what you have in store.

sulekhaji
13 Feb 2013, 4:03 AM
Hi,

We are using Extjs4 for exporting data in to CSV or Excel.After all the R&D we found that it is not possible as the Exporter.js and Exporter-all.js file is not updated for Ext4.0 version.
Please suggest any other ways so that we can Export Grid data in CSV directly from Extjs4 with Java or any server side code which can also help.

Please give us the links which are working.

Your suggestions will be valuable for me as we are bad stuck.:((

Thanks in advance.

Please help......

Sulekha

vicvolk
13 Feb 2013, 4:18 AM
Personally, I do it by PHP. I know this is a very bad way to do, but still working. I store the last db query in the current session, tune it with filterering, sorting or hiding if they were done and export data to excel, of course with all headers,subheaders, styling etc. It's a very-very bad way to do, but what is good - it does not depend on the extjs version.