標籤:style blog http color io os ar sp div
具體的:Base64編碼解碼還需要學習
/// <summary> /// base64 解碼Excel下載 /// </summary> /// <param name="excelContent"></param> /// <param name="strFileName"></param> public void BidExcelDown(string excelContent, string strFileName) { Response.Clear(); //清空無關資訊 Response.Buffer= true; //完成整個響應後再發送 Response.Charset = "GB2312";//設定輸出資料流的字元集-中文 Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");//設定輸出資料流的字元集 Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(strFileName + ".xls", System.Text.Encoding.UTF8));//追加頭資訊 Response.ContentType = "application/octet-stream";//輸出資料流的Excel類型 byte[] outputb = Convert.FromBase64String(excelContent); //解碼
//如果編碼是字串就無需這樣解碼了 //二進位的所以輸出的時候一定要記得帶上下面這句 Response.BinaryWrite(outputb);//輸出二進位的流 Response.End();//輸出停止 }
C# Base64解碼 二進位輸出