Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何浏览&;是否使用asp.net在web浏览器中显示excel工作表?_Asp.net_Excel - Fatal编程技术网

如何浏览&;是否使用asp.net在web浏览器中显示excel工作表?

如何浏览&;是否使用asp.net在web浏览器中显示excel工作表?,asp.net,excel,Asp.net,Excel,我想浏览excel输入文件并在web浏览器上显示它&它必须在web浏览器上可编辑, 我正在使用C#asp.net进行编码。任何帮助都是gr8。提前通知。我认为您可以选择HTML表格或Google电子表格/Microsoft Excel Online 有关更多信息: 在网络表单中: 代码隐藏: protected void UploadFile(object sender, EventArgs e) { string fileName = Path.GetFile

我想浏览excel输入文件并在web浏览器上显示它&它必须在web浏览器上可编辑,
我正在使用C#asp.net进行编码。任何帮助都是gr8。提前通知。

我认为您可以选择HTML表格或Google电子表格/Microsoft Excel Online

有关更多信息:

在网络表单中:


代码隐藏:

    protected void UploadFile(object sender, EventArgs e)
    {
        string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
        FileUpload1.PostedFile.SaveAs(Server.MapPath("~/Uploads/") + fileName);
        Response.Redirect(Request.Url.AbsoluteUri);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string[] filePaths = Directory.GetFiles(Server.MapPath("~/Uploads/"));
            List<ListItem> files = new List<ListItem>();
            foreach (string filePath in filePaths)
            {
                files.Add(new ListItem(Path.GetFileName(filePath), filePath));
                Fileddl.Items.Add(new ListItem(Path.GetFileName(filePath), Path.GetFileName(filePath)));
            }                              
        }
    }
    protected void OpenFile(object sender, EventArgs e)
    {
        
        string filePath = Fileddl.SelectedItem.Value;
        Myframe.Visible = true;
        Myframe.Attributes.Add("src", "https://view.officeapps.live.com/op/embed.aspx?src=https://www.yoursite.com/Uploads/" + Path.GetFileName(filePath));
    }
    protected void DownloadFile(object sender, EventArgs e)
    {
        string filePath = Fileddl.SelectedItem.Value;
        Response.ContentType = ContentType;
        Response.AppendHeader("Content-Disposition", "attachment; filename=https://www.yoursite.com/Uploads/" + Path.GetFileName(filePath));
        Response.WriteFile(filePath);
        Response.End();
    }
    
    protected void DeleteFile(object sender, EventArgs e)
    {
        string filePath = Fileddl.SelectedItem.Value;
        File.Delete(filePath);
        Response.Redirect(Request.Url.AbsoluteUri);
    }
受保护的无效上载文件(对象发送方,事件参数e)
{
string fileName=Path.GetFileName(FileUpload1.PostedFile.fileName);
FileUpload1.PostedFile.SaveAs(Server.MapPath(“~/Uploads/”)+fileName);
重定向(Request.Url.AbsoluteUri);
}
受保护的无效页面加载(对象发送方、事件参数e)
{
如果(!IsPostBack)
{
string[]filepath=Directory.GetFiles(Server.MapPath(“~/Uploads/”);
列表文件=新列表();
foreach(文件路径中的字符串文件路径)
{
添加(新列表项(Path.GetFileName(filePath),filePath));
添加(新列表项(Path.GetFileName(filePath),Path.GetFileName(filePath));
}                              
}
}
受保护的void OpenFile(对象发送方、事件参数e)
{
字符串filePath=Fileddl.SelectedItem.Value;
Myframe.Visible=true;
添加(“src”https://view.officeapps.live.com/op/embed.aspx?src=https://www.yoursite.com/Uploads/“+Path.GetFileName(filePath));
}
受保护的void下载文件(对象发送方,事件参数e)
{
字符串filePath=Fileddl.SelectedItem.Value;
Response.ContentType=ContentType;
AppendHeader(“内容处置”、“附件;文件名=https://www.yoursite.com/Uploads/“+Path.GetFileName(filePath));
Response.WriteFile(文件路径);
Response.End();
}
受保护的void DeleteFile(对象发送方,事件参数e)
{
字符串filePath=Fileddl.SelectedItem.Value;
File.Delete(文件路径);
重定向(Request.Url.AbsoluteUri);
}

欢迎来到StackOverflow。请包括解释,以及不只是代码。