博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
java 和 C# 响应输出的相似度
阅读量:6478 次
发布时间:2019-06-23

本文共 2483 字,大约阅读时间需要 8 分钟。

java servlet response:

bf.append("Shipment No, STT No, WIN Event, DateTime, WOU Envent, DateTime"); 					sbf.append('\n'); 					for(int i=0;i
byte[] csvData = sbf.toString().getBytes(); 					response.setHeader("Content-Disposition", "attachment;filename=Shipment Inventory Report.csv");   					response.setContentLength(sbf.length());   					response.setContentType("application/csv");   					response.setCharacterEncoding("UTF-8");   					response.getOutputStream().write(csvData);   					response.getOutputStream().flush();   					response.getOutputStream().close();

 

C# response

foreach (var totalCell in totalCellList)

{
totalContent.AppendFormat("\t{0},", totalCell.Value);
}

totalContent.AppendFormat("\t{0},", cellCountList.Values.Sum());

totalContent.AppendFormat("\t{0},", priceEvianBooCountList.Values.Sum());//依云及波多金额总计
totalContent.AppendFormat("\t{0},", pricefuWekoCountList.Values.Sum());//富维克金额总计
totalContent.AppendFormat("\t{0},", priceCountList.Values.Sum());//订单金额总计
sbContent.Append(totalContent.ToString());
//---------------------汇总行end------------------------//

sb.Append(sbContent.ToString());

var fileName = string.Format("{0}{1:yyyyMMddHHmmss}", (exporttype == 0 ? "日常报表_" : "详细报表_"), DateTime.Now);

userLogService.LogSuccessOperation(string.Format("导出报表[{0}.csv]!", fileName));

HttpContext.Current.Response.Clear();

HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.Buffer = false;
byte[] data = Encoding.Default.GetBytes(sb.ToString());
HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8) + ".csv");
HttpContext.Current.Response.ContentType = "application/octet-stream";
HttpContext.Current.Response.ContentEncoding = Encoding.GetEncoding("utf-8");
HttpContext.Current.Response.BinaryWrite(data);
HttpContext.Current.Response.Flush();

 

//------------------------------------------

if (Request.Content.IsMimeMultipartContent())

{
var path = HttpContext.Current.Server.MapPath("~/App_Data");
var provider = new MultipartFormDataStreamProvider(path);
var task = Request.Content.ReadAsMultipartAsync(provider);
task.ContinueWith(t =>
{
if (t.IsFaulted || t.IsCanceled)
throw new HttpResponseException(HttpStatusCode.InternalServerError);
});
}
else
{
throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotAcceptable, "This request is not properly formatted"));
}

转载于:https://www.cnblogs.com/fx2008/p/4241935.html

你可能感兴趣的文章
ClickStat业务
查看>>
spring3.0.7中各个jar包的作用总结
查看>>
Windows 10 /win10 上使用GIT慢的问题,或者命令行反应慢的问题
查看>>
Windows平台分布式架构实践 - 负载均衡
查看>>
iOS自定制tabbar与系统的tabbar冲突,造成第一次点击各个item图片更换选中,第二次选中部分item图片不改变...
查看>>
SVN服务器使用(二)
查看>>
反射获取内部类以及调用内部类方法
查看>>
App里面如何正确显示用户头像
查看>>
U-BOOT之一:BootLoader 的概念与功能
查看>>
我的路上
查看>>
Velocity处理多余空白和多余空白行问题
查看>>
DB2与oracle有什么区别
查看>>
创建一个多级文件目录
查看>>
Picasa生成图片幻灯片页面图文教程
查看>>
svn status 显示 ~xx
查看>>
常用HiveQL总结
查看>>
[转]使用Visual Studio Code开发Asp.Net Core WebApi学习笔记(三)-- Logger
查看>>
POJ 3311 Hie with the Pie(状压DP + Floyd)
查看>>
Security updates and resources
查看>>
DNS为什么通常都会设置为14.114.114.114
查看>>