Форум пользователей Visio

Форум по вопросам применения и программирования в Visio
Текущее время: 28 мар 2024, 23:58

Часовой пояс: UTC + 3 часа [ Летнее время ]


Правила форума


При размещении файлов предпочтительным является формат vsd (а не vsdx/vsdm)
Размещая ваши вложения на форуме не используйте имена файлов содержащих кириллицу, в противном случае файл будет иметь имя .<расширение файла> !

Для форматирования ваших сообщений используйте BBCodes, описание используемых на форуме BBCodes.



Начать новую тему Ответить на тему  [ Сообщений: 21 ]  На страницу Пред.  1, 2
Автор Сообщение
 Заголовок сообщения: Re: Не вставляется "AAA", но вставляется "4444"
СообщениеДобавлено: 30 мар 2018, 11:10 
Не в сети
Administrator

Зарегистрирован: 30 авг 2009, 11:02
Сообщений: 2253
Очков репутации: 100626

Добавить очки репутацииУменьшить очки репутации
Кстати, наткнулся на пример из документации (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;
      }
   }
}

Это чтобы можно было не только ААА вставить, но и ааа"ААА".


Пожаловаться на это сообщение
Вернуться к началу
 Профиль  
Ответить с цитатой  
Показать сообщения за:  Поле сортировки  
Начать новую тему Ответить на тему  [ Сообщений: 21 ]  На страницу Пред.  1, 2

Часовой пояс: UTC + 3 часа [ Летнее время ]



Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 4


Вы можете начинать темы
Вы можете отвечать на сообщения
Вы не можете редактировать свои сообщения
Вы не можете удалять свои сообщения
Вы не можете добавлять вложения

Найти:
Перейти:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Вы можете создать форум бесплатно PHPBB3 на Getbb.Ru, Также возможно сделать готовый форум PHPBB2 на Mybb2.ru
Русская поддержка phpBB