• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

java和C#响应输出的相似度

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

java servlet response:

bf.append("Shipment No, STT No, WIN Event, DateTime, WOU Envent, DateTime");
sbf.append('\n');

for(int i=0;i<list.size();i++)
{
PrintStatisticsForm psrform = list.get(i);
sbf.append(getCsvCommaString(psrform.getHawb()));
sbf.append(getCsvCommaString(psrform.getStt()));
sbf.append(getCsvCommaString(new HSSFRichTextString(psrform.getWinevent())));
sbf.append(getCsvCommaString(new HSSFRichTextString(psrform.getWindatetime())));
sbf.append(getCsvCommaString(new HSSFRichTextString(psrform.getWouevent())));
sbf.append(getCsvCommaString(new HSSFRichTextString(psrform.getWoudatetime())));
sbf.append('\n');
}
sbf.append('\n');
sbf.append('\n');
sbf.append('\n');
	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"));
}


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
AsynchronousC#server[转]发布时间:2022-07-10
下一篇:
C#锁定USB发布时间:2022-07-10
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap