Run c# program In Jenkins, cannot save Excel files

Usually get this error:

System.Runtime.InteropServices.COMException (0x800A03EC): Microsoft Excel cannot open or save any more documents

After SaveAs method

 

to solve this problem do this works:

  1. Create directory “C:\Windows\SysWOW64\config\systemprofile\Desktop ” (for 64 bit Windows) or “C:\Windows\System32\config\systemprofile\Desktop ” (for 32 bit Windows)
  2. Set Full control permissions for directory Desktop (for example in Win7 & IIS 7 & DefaultAppPool set permissions for user
    “IIS AppPool\DefaultAppPool”

 

See here foe more details:

 

How to add xml-stylesheet tags to an XML file using C#

http://stackoverflow.com/questions/2145736/how-to-add-xml-stylesheet-tags-to-an-xml-file-using-c

XmlDocument doc = new XmlDocument();
    doc.AppendChild(doc.CreateProcessingInstruction(
        "xml-stylesheet", 
        "type='text/xsl' href='xslFile.xslt'"));


- OR - 

http://stackoverflow.com/questions/1845699/cadd-xsl-reference-in-xmldocument

XmlDocument xDoc = new XmlDocument();
XmlProcessingInstruction pi = xDoc.CreateProcessingInstruction(
    "xml-stylesheet", 
    "type=\"text/xsl\" href=\"cdcatalog.xsl\"");
xDoc.AppendChild(pi);