In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how to derive CSV from ASP.NET WebAPI". In daily operation, I believe many people have doubts about how to derive CSV from ASP.NET WebAPI. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "how to derive CSV from ASP.NET WebAPI". Next, please follow the editor to study!
First, JS script window.open (".. / Ticket/ExportTicket"); second, background implementation code [HttpGet] public ActionResult ExportTicket (TicketSearch search) {if (search! = null) {search.CurrentPage = 1; search.PageSize = 0;} string [] lstTitles = new string [] {"number", "title"}; int TotalCount = 0; List lstTicketData = ListTicketEntityToData (search, out TotalCount); List lstData = new List () Foreach (TicketData itemData in lstTicketData) {string [] data = new string [] {itemData.Barcode, itemData.Label, itemData.SiteId.ToString (), Helper.Htmlhelper.GetSiteInfo (itemData.SiteId), itemData.Owner, string.IsNullOrEmpty (itemData.CardId)? "": itemData.CardId, itemData.StartDate = = null? ": itemData.StartDate.Value.ToString (" yyyy-MM-dd HH:mm ") ItemData.EndDate = = null? "": itemData.EndDate.Value.ToString ("yyyy-MM-dd HH:mm"), itemData.IsValid.ToString (), itemData.IsUsed.ToString (), itemData.CreateTime.ToString ("yyyy-MM-dd HH:mm")} LstData.Add (data);} string ExportFileName = Helper.ImportExport.ExportData (lstTitles, lstData); return File (new System.IO.FileStream (ExportFileName, System.IO.FileMode.Open), "application/octet-stream", "Ticket" + DateTime.Now.ToString ("yyyyMMddHHmmss") + ".csv") } public static string ExportData (string [] lstTitles, List lstData) {try {lock (RunningExport) {string TemplatePath = AppDomain.CurrentDomain.BaseDirectory + "Export"; string FullFileName = AppDomain.CurrentDomain.BaseDirectory + "Export\\ template.csv"; if (Directory.Exists (TemplatePath)) {if (File.Exists (FullFileName) File.Delete (FullFileName)) } else {Directory.CreateDirectory (TemplatePath);} if (lstTitles.Length
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.