Click here to Skip to main content
13,248,766 members (58,417 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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);

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.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";
                          Response.ContentType = "application/";

So I want to Remove Hyperlink from that Excel File.
suggest me what i do.
Posted 11-Nov-12 19:34pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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:

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

You can see details:
Remove Excel Hyperlink[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.171114.1 | Last Updated 12 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100