表格里有一列是
ButtonCellType link = new ButtonCellTyp();
link.ButtonType = ButtonType.LinkButton;
link.Text = "test.pdf";
link.OnClientClick = "return LinkAttFileClick(\""test.pdf"\")";
sheet.Cells[0, 1].CellType = link;
前端:
function LinkAttFileClick(fileName) {
var spread = document.getElementById(spid);
spread.CallBack(fileName);
}
FpSpread_ButtonCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e){
string fileFullName = "C:\\Users\\" + e.CommandName;
FileInfo file = new FileInfo(fileFullName);
if (file.Exists) {
HttpContext.Current.Response.ContentType = "application/pdf";
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=" + e.CommandName);
HttpContext.Current.Response.TransmitFile(fileFullName);
HttpContext.Current.Response.End();
}
}
点击spread的linkcell页面左下部就会出现JavaScript:void(0);导致文件无法下载,没有走前台也没有走后台。
但是用asp.net的button控件下载就没问题,是spread对其做了什么限制吗?
如果这种方法不行,那么怎么实现点击spread表格的link进行文件下载?
|