zoukankan      html  css  js  c++  java
  • java 和 C# 响应输出的相似度

    java servlet response:

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

    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(' ');
    }
    sbf.append(' ');
    sbf.append(' ');
    sbf.append(' ');
    	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(" {0},", totalCell.Value);
    }

    totalContent.AppendFormat(" {0},", cellCountList.Values.Sum());
    totalContent.AppendFormat(" {0},", priceEvianBooCountList.Values.Sum());//依云及波多金额总计
    totalContent.AppendFormat(" {0},", pricefuWekoCountList.Values.Sum());//富维克金额总计
    totalContent.AppendFormat(" {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"));
    }

  • 相关阅读:
    改了一下分辨率,Areo特效奇迹般的恢复了...
    此连接需要活动的Internet连接
    Apple Mac OS X每日一技巧026:Spotlight打开文件所在的文件夹
    WP7有约(八):在ListPicker控件的选择页面上播放铃声
    WP7有约(七):实现铃声设置的播放图标的效果
    WP7有约(五):回到主页
    WP7有约:一个应用的破蛋过程
    WP7有约(六):AppBarUtils使用指南
    IE与firefox事件处理
    C#试题
  • 原文地址:https://www.cnblogs.com/fx2008/p/4241935.html
Copyright © 2011-2022 走看看