打开Excel问题 + 5裤散分

accomp 2009-04-15 03:43:21
简单问题 ,懒得查了 ,散分+求解

有一excel文件 在服务器上:string strFileName = "aaa.xls";

点击button ,欲读成流,保存至本机 ,string strOutFileName = "bbb.xls";

越简单越好 。 要求有打开/保存/取消那个对话框 ,并且看不见原下载地址,即不支持迅雷等下载工具 。

原来用的是SpreadsheetGear,代码如下
protected void btnExcelOut_Click(object sender, ImageClickEventArgs e)
{
string strFileName = "/aaa/aaa.xls";

SpreadsheetGear.IWorkbook workbook = SpreadsheetGear.Factory.GetWorkbook(Server.MapPath( strFileName ));


strOutFileName = bbb.xls ;

Response.Clear();
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment; filename=" + strOutFileName );
workbook.SaveToStream(Response.OutputStream, SpreadsheetGear.FileFormat.Excel8);
Response.End();

}

上面写法,excel生成的饼图的示例位置变了 ,原因不明 。
...全文
148 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
路人乙e 2009-04-15
  • 打赏
  • 举报
回复
new System.Net.WebClient().DownloadFile("uri","local file name")
freewind0521 2009-04-15
  • 打赏
  • 举报
回复
mark
以前都是直接response到客户端,能看见地址的
gciyfzx07 2009-04-15
  • 打赏
  • 举报
回复
学习
xiaoyuzi 2009-04-15
  • 打赏
  • 举报
回复
string sGenName = "a.xls";
System.IO.FileStream fs = null;
fs = System.IO.File.Open(filepath, System.IO.FileMode.Open);
byte[] btFile = new byte[fs.Length];
fs.Read(btFile, 0, Convert.ToInt32(fs.Length));
fs.Close();

// File name with chinese not more than 16?
Response.AddHeader("Content-disposition", "attachment; filename=" + HttpUtility.UrlEncode(System.Text.Encoding.UTF8.GetBytes(sGenName)));
Response.ContentType = "application/vnd.ms-excel";
Response.BinaryWrite(btFile);
Response.End();
blestcc 2009-04-15
  • 打赏
  • 举报
回复
爭取早日擺脫那五倏褲子
baobei7758 2009-04-15
  • 打赏
  • 举报
回复
大热天的穿五条裤子.....热啊
cja03 2009-04-15
  • 打赏
  • 举报
回复
SpreadsheetGear.FileFormat.Excel8 看看是不是版本问题。
boywangliang 2009-04-15
  • 打赏
  • 举报
回复
学习
  
zgke 2009-04-15
  • 打赏
  • 举报
回复
使用WebClient.DownloadData ? 我是来接分的
shipengcheng 2009-04-15
  • 打赏
  • 举报
回复
你可以先把它读到数据集中。然后在把它写到本地的EXCEL里,就想先导入,在导出。
tailor_ms 2009-04-15
  • 打赏
  • 举报
回复
Milan!!! 帮顶!

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧