Форум пользователей Visio http://visio.getbb.ru/ |
|
Не вставляется "AAA", но вставляется "4444" http://visio.getbb.ru/viewtopic.php?f=6&t=1316 |
Страница 2 из 2 |
Автор: | Tumanov [ 30 мар 2018, 11:10 ] |
Заголовок сообщения: | Re: Не вставляется "AAA", но вставляется "4444" |
Кстати, наткнулся на пример из документации (Visio SDK) Код: Cell Value as String -------------------------------------------------------------------------------- Description: This class contains a method that sets the value of the specified Visio cell to the new string passed as a parameter. Requirements: Requires the StringToFormulaForString method in the String to Formula sample. Code: // StringValueInCell.cs // <copyright>Copyright (c) Microsoft Corporation. All rights reserved. // </copyright> // <summary>This file contains the implementation of the StringValueInCell // class.</summary> using System; namespace Microsoft.Samples.Visio.CSharp { /// <summary>This class demonstrates how to set a formula for the cell. /// </summary> public class StringValueInCell { /// <summary>This method is the class constructor.</summary> public StringValueInCell() { // No initialization is required. } /// <summary>This method sets the value of the specified Visio cell /// to the new string passed as a parameter.</summary> /// <param name="formulaCell">Cell in which the value is to be set /// </param> /// <param name="newValue">New string value that will be set</param> public void SetCellValueToString( Microsoft.Office.Interop.Visio.Cell formulaCell, string newValue) { try { // Set the value for the cell. formulaCell.FormulaU = StringToFormulaForString(newValue); } catch (Exception err) { System.Diagnostics.Debug.WriteLine(err.Message); throw; } } /// <summary>This method converts the input string to a Visio string by /// replacing each double quotation mark (") with a pair of double /// quotation marks ("") and then adding double quotation marks around /// the entire string.</summary> /// <param name="inputValue">Input string that will be converted /// to Visio String</param> /// <returns>Converted Visio string</returns> public static string StringToFormulaForString(string inputValue) { string result = ""; string quote = "\""; string quoteQuote = "\"\""; try { result = inputValue != null ? inputValue : String.Empty; // Replace all (") with (""). result = result.Replace(quote, quoteQuote); // Add ("") around the whole string. result = quote + result + quote; } catch (Exception err) { System.Diagnostics.Debug.WriteLine(err.Message); throw; } return result; } } } Это чтобы можно было не только ААА вставить, но и ааа"ААА". |
Страница 2 из 2 | Часовой пояс: UTC + 3 часа [ Летнее время ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |