第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

easyUI的datagrid中的數(shù)據(jù)導(dǎo)出成excel (Java語言)

easyUI的datagrid中的數(shù)據(jù)導(dǎo)出成excel (Java語言)

念念念念 2016-03-16 12:02:50
麻煩大神指教 ? 將easyUI的datagrid中的數(shù)據(jù)導(dǎo)出成excel 要怎么弄
查看完整描述

1 回答

?
luckyer

TA貢獻(xiàn)4條經(jīng)驗(yàn) 獲得超0個(gè)贊

首先引用 NPOI

代碼語言c# ??

也不知道樓主用的什么語言 ?希望能對(duì)樓主有幫助 ??

我不是大神 ?只是剛好照著例子做過導(dǎo)出excel ?說的不完善 和有錯(cuò)誤的地方要告訴我哦,不要讓我再繼續(xù)錯(cuò)下去了哦

?public FileResult DaochuExcel()

? ? ? ? {

? ? ? ? ? ? //創(chuàng)建Excel文件的對(duì)象

? ? ? ? ? ? NPOI.HSSF.UserModel.HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook();

? ? ? ? ? ? //添加一個(gè)sheet

? ? ? ? ? ? NPOI.SS.UserModel.ISheet sheet1 = book.CreateSheet("Sheet1");

? ?//獲取list數(shù)據(jù)

? ? ?? ?IQueryable<AliExpressOrderForm> qs = null;

? ? ? ?(這一段是查詢數(shù)據(jù))

? ? ? ? ? ? List<AliExpressOrderForm> ListInfo = qs.ToList(); ?

? ? ? ? ? ? NPOI.SS.UserModel.IRow row1 = sheet1.CreateRow(0);

? ? ? ? ? ? row1.Height = 3 * 265;

? ? ? ? ?? IFont cfont = book.CreateFont(); ?//自己設(shè)置的一個(gè)字體樣式

? ? ? ? ? ? ?cfont.FontName = "宋體";

? ? ? ? ? ? ?cfont.FontHeight = 1 * 256;

? ? ?row1.CreateCell(0).SetCellValue("訂單號(hào)"); ? //自己設(shè)置的標(biāo)題

? ? ? ? ??? row1.CreateCell(1).SetCellValue("訂單狀態(tài)");

? ? ? ? ? ?

? ? ? ? ? ? sheet1.SetColumnWidth(0, 20*256); ?//設(shè)置列寬

? ? ? ? ? ? sheet1.SetColumnWidth(1, 15*256);

? ? ? ? ?

? ? ? ? ? ? for (int i = 0; i < ListInfo.Count; i++)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? NPOI.SS.UserModel.IRow rowtemp = sheet1.CreateRow(i + 1);

? ? ? ? ? ? ? ? rowtemp.Height = 3*265;

? ? ? ? ? ? ??

? ? ? ? ? ? ? ? rowtemp.CreateCell(0).SetCellValue(ListInfo[i].order_number);

? ? ? ? ? ? ? ?

? ? ? ? ? ? ? ? ? ? rowtemp.Cells[0].CellStyle.Alignment = HorizontalAlignment.Center;

? ? ? ? ? ? ? ? ? ? rowtemp.Cells[0].CellStyle.VerticalAlignment = VerticalAlignment.Center;//這兩句是垂直居中和水平居中

? ? ? ? ? ? ? ? ? ? rowtemp.Cells[0].CellStyle.WrapText = true; //自動(dòng)換行

? ? ? ? ? ? ? ? ?? ?rowtemp.Cells[0].CellStyle.GetFont(book).FontName = "宋體";

? ? ? ??? ? rowtemp.Cells[0].CellStyle.GetFont(book).FontHeight = 1 * 256;


? ? ? ???rowtemp.CreateCell(1).SetCellValue(ListInfo[i].status); ?//把值寫到對(duì)應(yīng)的格子里

? ? ? ? ? ? ? ? rowtemp.CreateCell(2).SetCellValue(ListInfo[i].salesman);

? ? ? ? ? ??

? }


? ? ? ? ? ? Response.ContentType = "application/vnd.ms-excel;charset=UTF-8";

? ? ? ? ? ? // 寫入到客戶端?

? ? ? ? ? ? System.IO.MemoryStream ms = new System.IO.MemoryStream();


? ? ? ? ? ? book.Write(ms);

? ? ? ? ? ? ms.Seek(0, SeekOrigin.Begin);

? ? ? ? ? ? ms.Flush();

? ? ? ? ? ? ms.Position = 0;


? ? ? ? ? ? return File(ms, "application/vnd.ms-excel", "文件名.xls");


? ? ? ? }


查看完整回答
反對(duì) 回復(fù) 2016-03-16
  • 1 回答
  • 4 關(guān)注
  • 8400 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)