Error while reading XPS, created with a specific Excel function

Tsvetkov, Daniil 41 Reputation points
2022-09-06T07:02:07.83+00:00

Hi All

I faced an error while reading the XPS file that was created from the Excel from Office 365 build 2208.
Excel worksheet contains one function HYPERLINK and with next parameters

With this function, I have a link on the worksheet to create an e-mail to two recipients.
I exported this file into XPS and trying to read it with C# code (XPS format is needed to generate a preview in my program). But I'm getting the error while I call the method GetFixedDocumentSequence(): "'Failed to create a 'NavigateUri' from the text 'mailto:asd@John Wallace .com;qwe@Anonymous .com'.' Line number '22' and line position '3'.". Example of the code that causing error:

            try  
            {  
                string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Test.xps");  
                XpsDocument xpsDocument = new XpsDocument(filePath, FileAccess.Read);  
                FixedDocumentSequence fixedDocumentSequence = xpsDocument.GetFixedDocumentSequence();  //<-- error here  
            }  
            catch (Exception ex)  
            {  
                Console.WriteLine("Error: " + ex.Message);  
                Console.ReadKey();  
            }  

I have not any errors if HYPERLINK parameter contains only one recipient.
Also, issue with more than one recipient is not reproducible with the XPS, created with Office version before build 2201

Do you have any ideas how to resolve this issue?

Developer technologies | C#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
{count} votes

Answer accepted by question author
  1. Jack J Jun 25,316 Reputation points
    2022-09-13T05:24:59.573+00:00

    @Tsvetkov, Daniil , thanks for the feedback, based on my test, I also reproduced the same error with you when I used the XPS file created with Office 365, Excel version 2208. BTW, I could run the code without a problem when I used the XPS file created with office 2016. Therefore, I think it is the office version problem instead of the code problem.

    I recommend that you could do the version rollback by using the following command in the Run:

    "C:\Program Files\Common Files\microsoft shared\ClickToRun\officec2rclient.exe" /update user updatetoversion=16.0.14931.20132           ->this is version 2202  
    

    Hope this could help you.

    Best Regards,

    Jack


    If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.