Home » excel » java – Change display name for hyperlink in csv file while opening through Excel

java – Change display name for hyperlink in csv file while opening through Excel

Posted by: admin May 14, 2020 Leave a comment

Questions:

I have a java program that has been used to generate a CSV file. I have a column which contains link to some web pages. I want to put link on it with custom display name on it.

When I write =HYPERLINK("http://www.google.com","Google") on msExcel it gives me desired result. I wanted same from my java program. My program looks as follows:

res.setContentType(“application/csv”);

BufferedWriter sbs = new BufferedWriter(res.getWriter());

res.setHeader(“Content-Disposition”,”attachment;
filename=\”joblist.csv\””);

StringBuffer sb = new StringBuffer();

String link = “http://www.google.com“;

String hyperlink = “=HYPERLINK(\””+link+jo.getId()+”\”\”,\”\”Google\”)”;

sb.append(hyperlink);

I followed this link to add hyperlink on CSV file.
Can Excel interpret the URLs in my CSV as hyperlinks?

How to&Answers:

You can try this

"=HYPERLINK(""http://www.google.com"",""google"")","1234","yyyy"

Answer:

Unfortunately CSV is a text file format.
Thus it cannot contain a hyperlink.