Common problems with C # for Visio two development

Source: Internet
Author: User

1. Translation of Visio property values

People who have done Visio development know that the value of a property in Visio, which is Cell.formula, usually contains two pairs of double quotes (such as "XX"), and you need to remove the double quotes if you want to convert the value of the property to a normal string value. So the string you get from the formula value of the cell in Visio needs to be handled in the following ways:

public static string formulastringtostring (string formula)
        {
            const string onequote = ' \ ';
            Const string twoquotes = "\" \ "";
            String convertedformula = "";
            Try
            {
                Convertedformula = formula;
                if (Convertedformula.startswith (onequote) && Convertedformula.endswith (onequote))
                {
                    Convertedformula = convertedformula.substring (1, (convertedformula.length-2));
                    Convertedformula = Convertedformula.replace (twoquotes, onequote);
                }
            catch (Exception err)
            {
                Convertedformula = "";
            }
            return convertedformula;
        }

If you are writing to the formula of the cell in Visio, go through the reverse process, as follows:

public static string stringtoformulaforstring (string input)
        {
            const string quote = ' \ ';
            string result = "";
            if (input = = null)
            {return
                null;
            }
            result = input. Replace (quote, (quote + quote));
            result = quote + result + quote;
            return result;
        }

2. Gets the value of the specified cell for the given shape. In addition to Method 1, there is one way to get the value of the cell. This approach is better than using formula to get a string because the Visio2007 drop-down list "asset ownership". The corresponding cell value may be index (0,prop. Asset attribution. Format), But if you use the following method, you can get the exact value of it.

public static string Getshapecellvalue (Shape shapetarget, string strcelltype)
        {
        const string cust_prop_prefix = "Prop.";
            String shapecellvalue = String. Empty;
            if (Shapetarget.get_cellexistsu (Cust_prop_prefix + Strcelltype, (short) visexistsflags.visexistsanywhere)!= 0)
            {
                Shapecellvalue = formulastringtostring (SHAPETARGET.GET_CELLSU (Cust_prop_prefix + strcelltype). GET_RESULTSTR ( Visunitcodes.visnocast));
            }
            return shapecellvalue;
        }

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.