<summary>///export admit//</summary>///<returns></returns>public ActionResult Exportadmitbanktrans (Banktransquerymodel querymodel) {Hssfworkbook WorkBook = new Hssfworkbook (); Isheet sheet = Workbook.createsheet ("business statement"); IRow row = sheet. CreateRow (0);//Get style func<icellstyle> Getcellstyle = () =>{icellstyle CellStyle = Workbook.createcellstyle (); Cellstyle.alignment = Horizontalalignment.center;return Cellstyle;};i CellStyle HeaderStyle = Getcellstyle (); IFont Fontheade = Workbook.createfont (); fontheade.fontheightinpoints = 11; Fontheade.fontname = "Microsoft Jas Black"; fontheade.boldweight = (short) fontboldweight.bold;headerstyle.setfont (FontHeade); func<string, int, icell> Setcellstyle = (string celltext, int colindex) =>{icell cell = row. Createcell (colindex); sheet. Setcolumnwidth (Colindex, 9000); cell. Setcellvalue (celltext); cell. CellStyle = Headerstyle;return cell;}; Setcellstyle ("Supplier name", 0), Setcellstyle ("Purchase number", 1), Setcellstyle ("actual to Account", 2) Setcellstyle ("Date of Account", 3); int Rowstart = 1;var list = BankTransBll.Instance.GetAllBankTransRealList (Querymodel), if (list! = null) {foreach (var item in List) {IRow myrow = sheet. CreateRow (Rowstart); myrow. Createcell (0). Setcellvalue (item.companyname); myrow. Createcell (1). Setcellvalue (item. CONTRACTNO); Myrow. Createcell (2). Setcellvalue (item. Amount.tostring ("F2")); Myrow. Createcell (3). Setcellvalue (item. Rec_createtime. ToShortDateString ()); rowstart++;}} using (MemoryStream ms = new MemoryStream ()) {workbook.write (MS); byte[] buffers = Ms. ToArray (); return File (buffers, "application/vnd.ms-excel", String. Format ("{0}.xls", DateTime.Now.ToString ("Yyyymmddhhmmss")));}}
ASP. NET MVC uses Nopi to export Excel