这是c#
的代码,不过是读取硬盘的东西,你试试看
FileStream myFile = File.OpenRead("D:\\5.xls");
byte[] fileCont = new byte[myFile.Length];
myFile.Read(fileCont,0,(int)myFile.Length);
Page.Response.Clear();
Page.Response.AddHeader( "Content-Type", "application/vnd.ms-excel" );
Page.Response.AddHeader("Content-Disposition", "attachment;filename=" + "tt.xls" );
Page.Response.AddHeader("Content-Length", myFile.Length.ToString());
Page.Response.BinaryWrite(fileCont);
Response.Flush();
Page.Response.End();