none
Reading SignatureLine from Excel RRS feed

  • Question

  • hi,

    i want to read signature line present in Excel file... any help would be appreciated

    i had tried workbook.Signature Property.

    i need the signature line like following code do:

                        using (var document = WordprocessingDocument.Open(FILENAME, false))
                        {
                            _lstSigVar = document.MainDocumentPart.Document.Descendants<SignatureLine>().ToList();
                            if (_lstSigVar.Count > 0)//check if SigLine(s) present
                            {
                                for (int i = 0; i < _lstSigVar.Count; i++)
                                    lstSigners.Items.Add(_lstSigVar[i].Id + " " + _lstSigVar[i].SuggestedSigner);
                            }
                        }

    so by above code i got SignatureLine object which is easy to use for further processing



    Haseeb Hasan Principle Software Engineer Ascertia Pvt Ltd

    Thursday, March 20, 2014 2:00 PM

Answers

  • Hi,

    In word document , the SignatureLine object is saved in document.xml, but it is saved in xl/drawings/vmlDrawing1.vml, as far as I know , you can use the Openxml to get this SignatureLine,for the workaround ,you can use the XmlDocument class to read this attribute .

    I wrote a sample code for your reference:

    using System.IO;
    using System.Xml;
    using System.Xml.Linq;
            private void button1_Click(object sender, EventArgs e)
            {
                string sPptPath = @"D:\22.xlsx";
                var pkg = Package.Open(sPptPath, FileMode.Open, FileAccess.ReadWrite);
                // Specify the URI of the part to be read
                var uri = new Uri("/xl/drawings/vmlDrawing1.vml", UriKind.Relative);
                PackagePart part = pkg.GetPart(uri);
                var xmlMainXmlDoc = new XmlDocument();
                xmlMainXmlDoc.Load(part.GetStream(FileMode.Open, FileAccess.Read));
                XmlNode signatureline = xmlMainXmlDoc.GetElementsByTagName("o:signatureline").Item(0);
                var suggestedSigner = signatureline.Attributes["o:suggestedsigner"].Value;
                var suggestedsigner2 = signatureline.Attributes["o:suggestedsigner2"].Value;
                var suggestedsigneremail = signatureline.Attributes["o:suggestedsigneremail"].Value;
                pkg.Close();
            }
    

    Regards,

    Marvin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

    • Marked as answer by Haseeb Hasan Monday, March 24, 2014 6:04 AM
    Sunday, March 23, 2014 9:44 AM
    Moderator

All replies

  • Hi,

    In word document , the SignatureLine object is saved in document.xml, but it is saved in xl/drawings/vmlDrawing1.vml, as far as I know , you can use the Openxml to get this SignatureLine,for the workaround ,you can use the XmlDocument class to read this attribute .

    I wrote a sample code for your reference:

    using System.IO;
    using System.Xml;
    using System.Xml.Linq;
            private void button1_Click(object sender, EventArgs e)
            {
                string sPptPath = @"D:\22.xlsx";
                var pkg = Package.Open(sPptPath, FileMode.Open, FileAccess.ReadWrite);
                // Specify the URI of the part to be read
                var uri = new Uri("/xl/drawings/vmlDrawing1.vml", UriKind.Relative);
                PackagePart part = pkg.GetPart(uri);
                var xmlMainXmlDoc = new XmlDocument();
                xmlMainXmlDoc.Load(part.GetStream(FileMode.Open, FileAccess.Read));
                XmlNode signatureline = xmlMainXmlDoc.GetElementsByTagName("o:signatureline").Item(0);
                var suggestedSigner = signatureline.Attributes["o:suggestedsigner"].Value;
                var suggestedsigner2 = signatureline.Attributes["o:suggestedsigner2"].Value;
                var suggestedsigneremail = signatureline.Attributes["o:suggestedsigneremail"].Value;
                pkg.Close();
            }
    

    Regards,

    Marvin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

    • Marked as answer by Haseeb Hasan Monday, March 24, 2014 6:04 AM
    Sunday, March 23, 2014 9:44 AM
    Moderator
  • thanks marvin for taking out the time .... this actually solve my problem..

    please tell me if the document have multiple signatureline like 3 or 4 or more

    then what will be this line like:

    XmlNode signatureline = xmlMainXmlDoc.GetElementsByTagName("o:signatureline").Item(0);

    would it be like this:

    XmlNodeList signatureline = xmlMainXmlDoc.GetElementsByTagName("o:signatureline");


    Haseeb Hasan Principle Software Engineer Ascertia Pvt Ltd

    Monday, March 24, 2014 5:55 AM
  • Hi,

    Yes, you are right.

    Here is a screenshot for vmlDrawing1.vml, you can add mutiple signaturelines in excel worksheet.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, March 24, 2014 6:27 AM
    Moderator
  • hi marvin,

    i got an issue while reading signatureline,

    i have noticed that Excel is adding separate vmlDrawing.vml in the package

    when i am adding new signature line...e.g i have added 3 signaturelines and it make three files like: vmlDrawing1.vml,vmlDrawing2.vml,vmlDrawing3.vml,

    and each document only contain the content related to signature-line...

    so with the code mentioned above..it is not possible to get all the signaturelines...rather some more improved logic would be required.


    Haseeb Hasan Principle Software Engineer Ascertia Pvt Ltd

    Monday, March 24, 2014 12:25 PM