Hyperlink with escaped characters

I have some code that is dynamically create a string (with escape characters) for hyperlink. The text is like this:
var link = “=HYPERLINK(”\\servername\Upload\filename.pdf"|“filename.pdf”)";

However, whenever I try to run this it gives me an error Invalid ‘"’(Based on cell Data!Z18). Is this because of the escape characters?

@tkurian,
For the parameter of HYPERLINK function, the ‘"’ should be escaped too in your program. Please confirm the formula you need to set for cell is valid and can be set in ms excel manually. And please provide a text file contains your sample code so we can know what’s the exact formula string you set for the formula and then we can figure the issue out.

Here’s how my Hyperlink looks with escaped characters:

=HYPERLINK(\"\\\\servername\\Upload\\FW_ Invoice.msg\"|\"\\\\servername\\Upload\\Fw_Invoice.msg\")

I have tried both
cell.Formula = (string)cell.Value; and cell.Formula = cell.Value.ToString()

I continue to get this error: Invalid ‘"’(Based on cell Data!AM18)

@tkurian,

I tried to use your formula =HYPERLINK(\"\\\\servername\\Upload\\FW_ Invoice.msg\"|\"\\\\servername\\Upload\\Fw_Invoice.msg\") in MS Excel manually but MS Excel prompts an invalid formula. We request you to kindly provide a sample console application (source code without compilation errors) with resource files, zip the project and post us to reproduce the issue on our end. We will check your issue soon.

Please understand that the " and \ in C# are reserved so they must be escaped. So that’s how I form the string. In reality the string resolves to this:

=HYPERLINK("\servername\Upload\FW_ Invoice.msg"|"\servername\Upload\Fw_Invoice.msg")

@tkurian,

What’s the region you are using? Maybe for your region ‘|’ is the list separator? If so, please change it to ‘,’ which is the default list separator we support for setting formulas.

@tkurian
Please use “” replace " in the string parameter of the formula as the following:

 Workbook t = new Workbook();
            t.Worksheets[0].Cells["A1"].Formula = "HYPERLINK(\"\\\\servername\\Upload\\FW_ Invoice.msg\"\" | \"\"\\servername\\Upload\\Fw_Invoice.msg\")";
            t.CalculateFormula();
            Console.WriteLine(t.Worksheets[0].Cells["A1"].Value); 

I changed the | to comma (,) for Hyperlink and it worked thanks your help.

@tkurian,

Good to know that your issue is sorted out by using the suggestion. In the event of further queries or issue, feel free to write us back.