Java poi execl export and javapoiexecl Export

Source: Internet
Author: User

Java poi execl export and javapoiexecl Export

First, paste the exported execl:

The front-end interface is as follows:

When you click Export, add the exportDate () function for the onclick event of its button:

function exportDate(){            var begin_Date=$('#dateid').datebox('getValue');            document.getElementById("exportForm").action="../mobileManage/export.do?begin_Date="+begin_Date;            document.getElementById("exportForm").submit();        }

The code for export. do in the background is as follows:

@ RequestMapping ("export. do ") public void exportExecl (HttpServletRequest request, HttpServletResponse response) {String beginDate = request. getParameter ("dateid") + "-01"; int maxDay = getCurrMonthDays (beginDate); List <MobileManage> list = getDataList (beginDate); String title = beginDate. substring (0, 4) + "year" + beginDate. subSequence (5, 7) + "month" + "employee work details table"; String [] headers1 = new String [33]; // Date of the table header 1 array, 3. .. String [] headers2 = new String [31]; // header 2 array week, one, two, three... headers1 [0] = "type"; headers1 [1] = "name"; for (int I = 1; I <= maxDay; I ++) {String date = beginDate. substring (0, 8) + (I <10? "0" + I: I + ""); String week = getWeek (date); headers1 [I + 1] = I + ""; headers2 [I-1] = week ;} HSSFWorkbook workbook = new HSSFWorkbook (); // generate a workbook HSSFSheet sheet = workbook. createSheet (title); // create a table HSSFCellStyle = workbook. createCellStyle (); // create a center style. setAlignment (HSSFCellStyle. ALIGN_CENTER); // horizontal style. setverticalignment (HSSFCellStyle. VERTICAL_CENTER); // vertical sheet. setdefacolumcolumnwidth (5 );// Sets the default column width sheet. setColumnWidth (0, 10*256); // you can specify the width of the first and second columns. setColumnWidth (1, 10*256); sheet. setDefaultRowHeight (short) 300); // you can specify HSSFRow row = sheet. createRow (0); // create a table header. addMergedRegion (new CellRangeAddress (0, 1, 0, 0); // sets cross-row sheet. addMergedRegion (new CellRangeAddress (0, 1, 1, 1); HSSFRow rowWeek = sheet. createRow (1); // create table header two HSSFCell cell = null; // fill the table header with data for (int I = 0; I 

I have seen many people on the internet saying that short should be added for configuration purposes, but it is no problem for me to write it in Firefox Google for export, of course, there may be problems with different browsers. If so, let's talk about it later.

 

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.