Similarity of Java and C # response output

Source: Internet
Author: User
Tags httpcontext

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 ());//Evian and Wave sum total
Totalcontent.appendformat ("\t{0},", PricefuWekoCountList.Values.Sum ());//Fouvic Total Amount
Totalcontent.appendformat ("\t{0},", PriceCountList.Values.Sum ());//Total Order Amount
Sbcontent.append (Totalcontent.tostring ());
---------------------Summary Line End------------------------//

Sb. Append (Sbcontent.tostring ());

var fileName = string. Format ("{0}{1:YYYYMMDDHHMMSS}", (Exporttype = = 0?) "Daily Report _": "Detailed Report _"), DateTime.Now);
Userlogservice.logsuccessoperation (String. Format ("Export report [{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 ();

Similarity of Java and C # response output

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.