具体的: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();//输出停止 }
时间: 2024-11-02 15:29:16