如何删除从磁盘读取的Excel文件的超链接 [英] How to Remove Hyperlink of Excel File which read from Disk

查看:91
本文介绍了如何删除从磁盘读取的Excel文件的超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好ALl,


我已经将报告保存在Excel中,此后,当我打开Excel文件时,所有超链接都必须删除,因为它要求提供Credintials.


因此,请建议我如何从从磁盘读取的Excel文件中删除HyperLink.

我只是使用以下代码保存报告:

Hello ALl,


I have save Report in Excel and after that when i Open Excel file that time all hyperlink I have to remove Because its asking for Credintials.


So please suggest me how to Remove HyperLink from Excel file which is read from Disk.

I just save report using below Code:

 string FilterFileName = (reportBll.GetFilterID() + 1).ToString() + "_" + pageTitle + "_" + System.DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss").Replace("/", "").Replace(" ", "").Replace(":", "") + ".xls";
                    string Folderpath = "";
                 
 Warning[] warnings;
 string[] streamids;
 string mimeType;
 string encoding;
 string extension;
byte[] bytes = rptViewer.ServerReport.Render("Excel", null, out mimeType, out encoding,out extension,out streamids, out warnings);         
 FileStream fs = new FileStream(reportBll.FileCopyLocation(out Folderpath)+ "\\" +  FilterFileName, FileMode.Create);
 fs.Write(bytes, 0, bytes.Length);
 fs.Close();



以下代码用于保存在磁盘上的Open Excel文件



Below Code is for Open Excel File which is Save on Disk

string path = Config.Get("SaveFilterReport") + e.CommandArgument.ToString();
                    if (File.Exists(path))
                    {
                        Response.Buffer = true;
                        Response.Clear();
                        Response.ClearContent();
                        Response.Charset = "";
                        Response.AppendHeader("content-disposition", "attachment; filename=\"" + e.CommandArgument.ToString().Remove(0, e.CommandArgument.ToString().LastIndexOf("\\")).Remove(0, e.CommandArgument.ToString().IndexOf("_")) + "\"");
                        if (path.Contains(".xlsx"))
                          Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                        else
                          Response.ContentType = "application/vnd.ms-excel";
                        Response.TransmitFile(path);
                        Response.Flush();
                        Response.Close();
                        Response.End();
                    }



因此,我想从该Excel文件中删除超链接.



So I want to Remove Hyperlink from that Excel File.
suggest me what i do.

推荐答案

有两个超链接,一个是仅无文本的超链接,另一个是在单元格中具有文本的超链接,称为锚文本,两者他们可以自动将您带到目标位置.
如果要删除所有包括超链接和单元格文本的内容,可以使用:
There are two hyperlinks, one is only hyperlink without text,the other is the hyperlink with text in cell called anchor text, both of them can take you automatically to the target place.
if you want to remove all including hyperlink and cell text, you can use:
sheet.Range["B5"].ClearAll();



对于第二种情况,可以删除超链接效果并保留单元格文本内容,请参见以下代码:



for the second case, you can remove hyperlink effect and keep the cell text content,see below code:

sheet.HyperLinks.RemoveAt(0);



您可以查看详细信息:
删除Excel超链接 [ ^ ]



You can see details:
Remove Excel Hyperlink[^]


这篇关于如何删除从磁盘读取的Excel文件的超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆