Specific: You need to learn more about base64 encoding and decoding.
/// <Summary> /// base64 decoded Excel File Download /// </Summary> /// <Param name = "excelcontent"> </param> // <Param name = "strfilename"> </param> Public void bidexceldown (string excelcontent, string strfilename) {response. clear (); // clear irrelevant information response. buffer = true; // send response after completing the response. charset = "gb2312"; // set the character set of the output stream-Chinese response. contentencoding = system. text. encoding. getencoding ("UTF-8"); // sets the character set response of the output stream. appendheader ("content-disposition", "attachment; filename =" + httputility. urlencode (strfilename + ". xls ", system. text. encoding. utf8); // append header information response. contenttype = "application/octet-stream"; // The Excel type byte [] outputb = convert of the output stream. frombase64string (excelcontent); // decode
// If the encoding is a string, it does not need to be decoded in this way. // when outputting binary data, remember to include the following response. binarywrite (outputb); // outputs the binary stream response. end (); // stop output}
C # base64 decoded binary output