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;
}