EXCEL 後台匯出

2021-08-03 18:13:37 字數 3534 閱讀 4942

request.setattribute("contenttype", "text/xml;charset=utf-8");

string parklotsname = request.getparameter("parklotsname");

parklotsname=new string(parklotsname.getbytes("iso8859-1"),"utf-8");

string intime = request.getparameter("intime");

string totime=request.getparameter("totime");

string paytype = request.getparameter("paytype");

******dateformat sdf = new ******dateformat("yyyy-mm-dd");

long time = 0l;

long endtotime=0l; //截止時間

try

if(!"".equals(totime))else

} catch (parseexception e1)

pdaordermng service = new pdaordermng();

listorderlist = new arraylist();

orderlist=service.querypdaorder(parklotsname,time,endtotime,paytype);

hssfworkbook wb = new hssfworkbook();

// 2.在workbook中新增乙個sheet,對應excel中的乙個sheet

hssfsheet sheet = wb.createsheet("交易明細");

// 3.在sheet中新增表頭第0行,老版本poi對excel行數列數有限制short

hssfrow row = sheet.createrow((int) 0);

// 4.建立單元格,設定值表頭,設定表頭居中

hssfcellstyle style = wb.createcellstyle();

// 居中格式

style.setalignment(hssfcellstyle.align_center);

row.setrowstyle(style);

// 設定表頭

hssfcell cell = row.createcell(0);

cell.setcellvalue("#");

cell.setcellstyle(style);

cell = row.createcell(1);

cell.setcellvalue("訂單編號");

cell.setcellstyle(style);

cell = row.createcell(2);

cell.setcellvalue("停車場名稱");

cell.setcellstyle(style);

cell = row.createcell(3);

cell.setcellvalue("泊位編號");

cell.setcellstyle(style);

cell = row.createcell(4);

cell.setcellvalue("車牌號");

cell.setcellstyle(style);

cell = row.createcell(5);

cell.setcellvalue("進入時間");

cell.setcellstyle(style);

cell = row.createcell(6);

cell.setcellvalue("離開時間");

cell.setcellstyle(style);

cell = row.createcell(7);

cell.setcellvalue("支付方式");

cell.setcellstyle(style);

cell = row.createcell(8);

cell.setcellvalue("應收金額");

cell.setcellstyle(style);

cell = row.createcell(9);

cell.setcellvalue("實收金額");

cell.setcellstyle(style);

cell = row.createcell(10);

cell.setcellvalue("員工編號");

cell.setcellstyle(style);

int i=0;

for(pdaorder bean:orderlist)else if(bean.gettrade_way().equals("0"))else if(bean.gettrade_way().equals("2"))else if(bean.gettrade_way().equals("3"))else if(bean.gettrade_way().equals("4"))else if(bean.gettrade_way().equals("5"))else if(bean.gettrade_way().equals("6"))else if(bean.gettrade_way().equals("7"))

row.createcell(8).setcellvalue(bean.getmoney());

row.createcell(9).setcellvalue(bean.getmoney());

row.createcell(10).setcellvalue(bean.getuserno());

}date date = new date();

******dateformat sf = new ******dateformat("yyyymmddhhmmss");//設定日期格式

string filename = "交易明細"+sf.format(date);

bytearrayoutputstream os = new bytearrayoutputstream();

wb.write(os);

byte content = os.tobytearray();

inputstream is = new bytearrayinputstream(content);

response.reset();

response.setheader("content-disposition", "attachment;filename="

+ new string((filename + ".xls").getbytes(), "iso-8859-1"));

servletoutputstream out = response.getoutputstream();

bufferedinputstream bis = null;

bufferedoutputstream bos = null;

try

} catch (exception e) finally

Ecahrts傳後台匯出Excel

記錄我遇到的坑 首先定義echarts圖乙個 必須給寬高 和顯示 在這一步 有兩個重點注意的 1.在echarts的載入option裡 配置 animation false 去掉載入時候的動畫效果 如果不去掉 獲取到的echart的圖 不全 因為有動畫 2.獲取的方法 mychart.getdata...

Vue結合後台詳解匯入匯出Excel問題

vue完整前後臺專案介紹 最近vue專案中用到了匯入匯出功能,在網上搜尋了一番之後,決定採用blob方式,這也是大家推薦的一種的方式,特此做下記錄。匯出excel功能 這裡不談別人怎麼實現的,我是從後台生成了excel流檔案返回給前端的。下面具體看一下後台的 批量匯出使用者 使用者列表 respon...

C 匯出Excel 匯出資料到Excel模板檔案裡

using excel microsoft.office.interop.excel using system.reflection missing 開啟模板檔案,得到workbook物件 workbook excel.workbooks.open templatepath,missing,miss...