//Export Excel functionExportexcel (obj) {varSaleorderno = $ ("#SaleOrderNo"). Val (). Trim (); varFoctoryno = $ ("#FoctoryNo"). Val (). Trim (); varStyleno = $ ("#StyleNo"). Val (). Trim (); varhref = "/admin/sale/exportpressingexcel?1=1"; if(Saleorderno = = "" && Foctoryno = = "" && Styleno = = "") {href= "/admin/sale/exportpressingexcel"; } Else if(Saleorderno! = "") {href+ = "&saleorderno=" +Saleorderno; } Else if(Foctoryno! = "") {href+ = "&foctoryno=" +Foctoryno; } Else if(Styleno! = "") {href+ = "&styleno=" +Styleno; } obj.href=href;}
<class= "btn Btn-app" onclick= "Exportexcel (this)"> <class= "fa fa-edit"></i> export Excel </ a >
/// <summary> ///processing single Export Excel/// </summary> /// <returns></returns> PublicActionResult Exportpressingexcel () {stringFoctoryno = request.params["Foctoryno"]; stringStyleno = request.params["Styleno"]; stringSaleorderno = request.params["Saleorderno"]; List<Factory> flist =fservice.getallfactory (); List<Factory> alist =NewList<factory>(); if(Flist! =NULL) { for(inti =0; i < Flist.count; i++) {Factory F=NewFactory (); F.factoryid=Flist[i]. Factoryid; F.factoryname=Flist[i]. Factoryname; F.tel=Flist[i]. Tel; F.mobile=Flist[i]. Mobile; F.mailbox=Flist[i]. MailBox; F.addr=Flist[i]. ADDR; Alist.add (f); }} List<Processing> pList =pservice.getexcelprocessing (Foctoryno, Styleno, Saleorderno); List<Processing> rList =NewList<processing>(); if(PList! =NULL) { for(inti =0; i < Plist.count; i++) {processing S=Newprocessing (); S.processingid=Plist[i]. Processingid; S.saleorderno=Plist[i]. Saleorderno; S.stoneoutno=Plist[i]. Stoneoutno; S.factoryid=Plist[i]. Factoryid; S.receivedate=Plist[i]. Receivedate; S.customermanager=Plist[i]. Customermanager; S.foctoryuser=Plist[i]. Foctoryuser; S.foctoryno=Plist[i]. Foctoryno; S.styleno=Plist[i]. Styleno; S.CUSTOMERSC=Plist[i]. CUSTOMERSC; S.material=Plist[i]. Material; S.requirement=Plist[i]. requirement; S.sizej=Plist[i]. Sizej; Switch(Plist[i]. Completedstatus) { Case "0": S.completedstatus="not completed"; Break; Case "1": S.completedstatus="Complete"; Break; Case "2": S.completedstatus="Cancel"; Break; default: S.completedstatus="not completed"; Break; } rlist.add (s); }} DataTable Table=NewDataTable (); Table. Columns.Add (NewDataColumn ("Factory Waybill")); Table. Columns.Add (NewDataColumn ("Order Number")); Table. Columns.Add (NewDataColumn ("Processing Plants")); Table. Columns.Add (NewDataColumn ("date of delivery of the factory")); Table. Columns.Add (NewDataColumn ("out of stock number")); Table. Columns.Add (NewDataColumn ("Account Manager")); Table. Columns.Add (NewDataColumn ("factory receiver.")); Table. Columns.Add (NewDataColumn ("model number")); Table. Columns.Add (NewDataColumn ("Customer Hand inch")); Table. Columns.Add (NewDataColumn ("Material")); Table. Columns.Add (NewDataColumn ("Lettering Requirements")); Table. Columns.Add (NewDataColumn ("Gold Weight")); Table. Columns.Add (NewDataColumn ("Status")); foreach(varOinchrList) {DataRow row=table. NewRow (); row["Factory Waybill"] =O.foctoryno; row["Order Number"] =O.saleorderno; foreach(varIteminchalist) { if(O.factoryid = =item. Factoryid) {row["Processing Plants"] =item. Factoryname; }} row["date of delivery of the factory"] =o.receivedate; row["out of stock number"] =O.stoneoutno; row["Account Manager"] =O.customermanager; row["factory receiver."] =O.foctoryuser; row["model number"] =O.styleno; row["Customer Hand inch"] =O.CUSTOMERSC; row["Material"] =o.material; row["Lettering Requirements"] =o.requirement; row["Gold Weight"] =O.sizej; row["Status"] =O.completedstatus; Table. Rows.Add (row); } MemoryStream MemoryStream=NewMemoryStream (); Hssfworkbook Work=Excelhelper.createexcelbynpoi (table); Work. Write (MemoryStream); returnFile (Memorystream.getbuffer (),"Application/ms-excel","Processing Single-"+ DateTime.Now.ToString ("YYYYMMDDHHMMSS") +". xls");}
---------------------------------------------------------------------------------------------------------
Reprint please remember the author and source Oh-.-
Kingdudu
Original source: http://www.cnblogs.com/kingdudu/p/4913250.html
---------------------------------------------------------------------------------------------------------
"17th" Easyui-datagrid export Excel (in the client can pop up the download box)