Home > Web Front-end > JS Tutorial > body text

ExtJS4 dynamically generated grid export to excel example_extjs

WBOY
Release: 2016-05-16 16:50:32
Original
1851 people have browsed it

After searching for a long time, I found some examples. Most of them don't know how to use them because I am a beginner. .

I studied the source code and finally achieved basic downloading. Solved a small BUG that the table cannot be downloaded repeatedly, and a BUG that occurred when using grid initialization

The steps are recorded below. Maybe it will be useful next time

1. Downloading requires js code, I have already uploaded it

2. Add a reference to your html file, the path problem is yours Note, the following is my path

Copy code The code is as follows:

;

3. In the Ext of the JS code you want to use. Add

Ext.Loader.setConfig ({ enabled: true });
Ext.Loader.setPath('Ext.ux.exporter', '../export/exporter');
Ext.require([
'Ext.ux .exporter.Exporter'
]);

Set the namespace. . Pay attention to the path

4. Use it in the code and add

xtype: 'exporterbutton',
// store: store
component: Ext.getCmp('gird_a')

These are two ways to initialize excel. One is to initialize with store, using the fields and data of the store. Because the fields names in my store are in English and the exported column names are in English, I did not use this method, but Initialize directly with grid.

The following is what I modified based on other people’s code

1. In line 40 of exporter.js, it was changed to
Copy code The code is as follows:

var columns = Ext.Array.filter(grid.columnManager.columns,

The original code had grid.columns in the first parameter. Later I found that the columns of the dynamically generated grid were placed in columnManager.columns after reconfigure, so I changed it like this


2. In workbook.js In line 77.78, add two sentences
Copy the code The code is as follows:

this.styles =[];
this.worksheets=[];

The above 2 lines of code perform some initialization, otherwise every time excel is generated, it will cause a format error because the previous data is not cleared

After the above simple modifications, a grid can be exported at will, and table export of customized fields is supported, that is, the columns displayed in the export table

The rendering is here:
ExtJS4 dynamically generated grid export to excel example_extjs
ExtJS4 dynamically generated grid export to excel example_extjs
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template