Click here to Skip to main content
11,812,712 members (72,826 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# ASP.NET
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 18: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
0 Abhinav S 205
1 CHill60 180
2 KrunalRohit 169
3 Palash Mondal_ 140
0 OriginalGriff 3,877
1 KrunalRohit 2,496
2 CPallini 2,240
3 Maciej Los 2,205
4 ppolymorphe 1,750

Advertise | Privacy | Mobile
Web03 | 2.8.151002.1 | Last Updated 12 Nov 2012
Copyright © CodeProject, 1999-2015
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