Aspose.cell生成表格
生活随笔
收集整理的這篇文章主要介紹了
Aspose.cell生成表格
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
public?void?ExportQueryPrj(HttpContext?context){?//接受前端傳遞參數和數據string?datasource?=?context.Request["queryResult"];?//序列化后的json字符串List<QueryXM>?queryList?=?JSONStringToList<QueryXM>(datasource);????//反序列化json字符串為listif?(queryList.Count?>?0){Workbook?workbook?=?new?Workbook();//工作薄Worksheet?worksheet?=?workbook.Worksheets[0];//工作表Cells?cells?=?worksheet.Cells;//單元格//表頭部分cells[0,?0].PutValue("索引值");cells[0,?1].PutValue("項目ID");cells[0,?2].PutValue("用地位置");cells[0,?3].PutValue("項目名稱");cells[0,?4].PutValue("建設單位");cells[0,?5].PutValue("用地性質");cells[0,?6].PutValue("用地面積");cells[0,?7].PutValue("項目類型");cells[0,?8].PutValue("紅線類別");cells[0,?9].PutValue("用地分類");cells[0,?10].PutValue("BELONGTFZX");cells[0,?11].PutValue("TDCRSTATUS");cells[0,?12].PutValue("TDYT");cells[0,?13].PutValue("JSYDFL");//調整寬度cells.SetColumnWidth(2,?40);cells.SetColumnWidth(3,?60);cells.SetColumnWidth(4,?80);cells.SetColumnWidth(7,?40);cells.SetColumnWidth(8,?20);//內容for?(int?i?=?0;?i?<?queryList.Count;?i++){cells[i+1,?0].PutValue(queryList[i].OBJECTID);cells[i?+?1,?1].PutValue(queryList[i].PrjID);cells[i?+?1,?2].PutValue(queryList[i].FADDRESS);cells[i?+?1,?3].PutValue(queryList[i].PRJNAME);cells[i?+?1,?4].PutValue(queryList[i].FCOMPANY);cells[i?+?1,?5].PutValue(queryList[i].YDXZ);cells[i?+?1,?6].PutValue(queryList[i].YDMJ);cells[i?+?1,?7].PutValue(queryList[i].XMLX);cells[i?+?1,?8].PutValue(queryList[i].TYPE);cells[i?+?1,?9].PutValue(queryList[i].YDFL);cells[i?+?1,?10].PutValue(queryList[i].BELONGTFZX);cells[i?+?1,?11].PutValue(queryList[i].TDCRSTATUS);cells[i?+?1,?12].PutValue(queryList[i].TDYT);cells[i?+?1,?13].PutValue(queryList[i].JSYDFL);cells.SetRowHeight(i?+?1,?25);??//設置行高}string?filepath=?"../Aspose/QueryExcel/項目查詢報告"+DateTime.Now.ToString("yyyymmddHHmmss")+".xls";string?fileServerPath?=?context.Server.MapPath(filepath);if?(!File.Exists(fileServerPath)){var?myfile?=?File.Create(fileServerPath);myfile.Close();}workbook.Save(fileServerPath);//按照json格式返回前端數據ResponseResult?response?=?new?ResponseResult()?{?responseMark?=?1,?responseObject?=?filepath?};context.Response.Write(new?JavaScriptSerializer().Serialize(response));}}
轉載于:https://www.cnblogs.com/sguozeng/p/9230514.html
總結
以上是生活随笔為你收集整理的Aspose.cell生成表格的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: js 和C# ashx之间数组参数传递问
- 下一篇: mysql/mariadb应该使用utf