[ExtJS5 Study notes] 34th section Sencha ExtJS 5 grid table Java Background export Excel

Source: Internet
Author: User

After the last use of the JS front-end export of Excel, another major concern is the background implementation of the export Excel, because I developed the use of Java so here using Apache Open Source project poi for the background Excel export.

This document folder

      • This document folder
        • POI Item Download and onboarding
        • ExtJS Front-End export settings
        • ExtJS the corresponding solution in the background
          • Create an Excel workbook
          • Create an Excel tab
          • Generate an Excel style and initialize
          • Generate table header row build headers
          • Construct data row Build rows

POI Item Download and onboarding

The POI project is an open source project on the Apache website, and its main purpose is to encapsulate Microsoft's Office software so that users can write it in a coded manner.
Project Open Source URL: Apache poi:http://poi.apache.org/
By the time the article was written, the latest version number was 3.1.1. After the download bin package is decompressed, add the jar package (jar package in the image below) to the project Lib:

Ok. Self-test whether the normal increase in the project library will be able to.

ExtJS Front-End export settings

Adding the bottom gridtoolbar content in the front-end ExtJS Grid Adds an export Excelbutton, adds processing events, and associates the processing event to the background action.

exportexyjsGrid: function (grid) {//关联后台,传入须要的參数}
ExtJS the corresponding solution in the background

Action handling in the background:

Create an Excel workbook
HSSFWorkbook workbook = new HSSFWorkbook();
Create an Excel tab
HSSFSheet sheet = workbook.createSheet("页签标题");
Generate an Excel style and initialize
HSSFCellStyle style = workbook.createCellStyle();
Generate table header row (build headers)
    HSSFRow row = sheet.createRow(0);    for (int i = 0; i < headers.length; i++) {        HSSFCell cell = row.createCell(i);        cell.setCellStyle(style);        HSSFRichTextString text = new HSSFRichTextString(headers[i]);        cell.setCellValue(text);    }
Constructing data rows (build rows)

As with the header row, traverse the foreground incoming grid argument to find the store filter parameters to traverse the inserted Excel data row and populate the data.

This article mainly uses the Markdown editor function:
1. Code highlighting
2. Image upload
3. Title Folder

[ExtJS5 Study notes] 34th section Sencha ExtJS 5 grid table Java Background export Excel

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.