How to encode a hyperlink in CSV formatted file?

前端 未结 4 608
耶瑟儿~
耶瑟儿~ 2020-12-14 14:59

When I try to encode a HTML anchor link in CSV file cell it becomes corrupted and not readable by Excel.

Is there some sort of non-HTML solution or format to encode

4条回答
  •  旧时难觅i
    2020-12-14 15:49

    What worked for me in Excel 2003 - output to your CSV the statement:

    CELLVALUE="=HYPERLINK("+QM+URLCONTENTS+QM+";"+QM+"URLDISPLAYNAME"+QM+")" 
    
    • note the semicolon ; use in the hyperlink. I've found the comma not to work for me in Excel 2003.
    • Depending on the script or language you use quotemarks could be handled differently. The cellvalue you put into the CSV before you import it into Excel should look exactly like this: "=HYPERLINK("URLCONTENTS";"URLDISPLAYNAME")"

    where:

    • CELLVALUE is the output written to the CSV
    • QM is the ASCII value of ["] -> (ASCII 34)
    • URLCONTENTS is the full URL to the page you want to link to. -URLDISPLAYNAME is the text you see in the Excel cell.
  • You can also use relative paths and set a base location in Excel.

    File/Properties > Tab Summary > Field Hyperlink Base.

    Use as fieldvalue something like http://www.SITENAME.com/SUB_LOCATION/../SUB_LOCATION that sets your starting point so you can click it in Excel. Of course, you don't have to use SUB_LOCATIONs if the sitename itself already will resolve successfully for your relative path.

    What I couldn't find is how to make the links automatically underlined in Excel. From other tips found in this article:

    Format manually all linkcells as underlined and darkblue (for example) and then the standard functionality appears with already visited links turning into another color.

提交回复
热议问题