Excel 테이블 내보내기를 위한 controller 레이어

2808 단어

 

3 Controller 레이어에서 Excel 테이블 내보내기

@RequestMapping("/importExc")
@ResponseBody
    public String importExc(HttpSession session){
        // 
    boolean flag=false;
        // 
    HSSFWorkbook hwb=new HSSFWorkbook();
    // Excel , 
    HSSFSheet sheet = hwb.createSheet(" ");
    // 
   /* sheet.setColumnWidth("0",2000);*/

    // 
    HSSFRow hrow = sheet.createRow(0);
    // 
    HSSFCell [] hssfCells=new HSSFCell[8];

    // 
    for (int i=0;i functionList = (List) session.getAttribute("functionList");
    for (int i=0; i

4 xml 파일을 데이터베이스로 가져오기

package com.offcn.controller;

import com.offcn.entity.Forum;
import com.offcn.service.ForumService;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Controller
public class ForumController {
    @Resource
    private ForumService forumService;
    @RequestMapping("doForm")
    @ResponseBody
    public String doForm(){
        boolean flag=true;
        List forumList=new ArrayList<>();
        try {
            FileInputStream fid=new FileInputStream("D:\\up\\data.xls");
            HSSFWorkbook hwb=new HSSFWorkbook(fid);


            for (int i=0;i0) {
        return "1";
    }
}
        return "2";
    }
}

좋은 웹페이지 즐겨찾기