SmartTag.CellText-Eigenschaft (2007 System)
Aktualisiert: November 2007
Ruft den Text aus der Zelle ab, die an die Erkennung gesendet wird.
Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)
Syntax
'Declaration
Protected ReadOnly Property CellText As String
'Usage
Dim value As String
value = Me.CellText
protected string CellText { get; }
Eigenschaftenwert
Typ: System.String
Der Text aus der Zelle, die an die Erkennung gesendet wird.
Hinweise
Diese Eigenschaft ist nur zur Verwendung durch die Recognize-Methode vorgesehen.
Beispiele
Im folgenden Codebeispiel wird veranschaulicht, wie die Recognize-Methode innerhalb einer Klasse überschrieben wird, die aus Microsoft.Office.Tools.Excel.SmartTag abgeleitet wird. Bei dieser Implementierung von Recognize wird jeder Smarttagbegriff mit dem Inhalt der Zelle verglichen. Wenn in der Zelle ein Smarttagbegriff gefunden wird, wird im Code eine benutzerdefinierte Smarttageigenschaft hinzugefügt, und dann wird die PersistTag(ISmartTagProperties)-Methode zum Erkennen des Smarttags verwendet. In diesem Beispiel wird davon ausgegangen, dass Sie von der Registerkarte COM im Dialogfeld Verweis hinzufügen einen Verweis auf die Microsoft Smart Tags 2.0-Typbibliothek hinzugefügt haben. Dieses Codebeispiel ist Teil eines umfangreicheren Beispiels, das für die SmartTag-Klasse bereitgestellt wird.
Protected Overrides Sub Recognize(ByVal text As String, _
ByVal site As ISmartTagRecognizerSite, _
ByVal tokenList As ISmartTagTokenList)
' Determine whether each smart tag term exists in
' the document text.
Dim Term As String
For Each Term In Me.Terms
' Search the cell text for the first instance of
' the current smart tag term.
Dim index As Integer = Me.CellText.IndexOf(Term, 0)
If (index >= 0) Then
' Create a smart tag token and a property bag for the
' recognized term.
Dim propertyBag As ISmartTagProperties = _
site.GetNewPropertyBag()
' Write a new property value.
Dim key As String = "Key1"
propertyBag.Write(key, DateTime.Now)
' Attach the smart tag to the term in the document
Me.PersistTag(propertyBag)
' This implementation only finds the first instance
' of a smart tag term in the cell.
Exit For
End If
Next
End Sub
protected override void Recognize(string text,
ISmartTagRecognizerSite site, ISmartTagTokenList tokenList)
{
// Determine whether each smart tag term exists in
// the document text.
foreach (string term in this.Terms)
{
// Search the cell text for the first instance of
// the current smart tag term.
int index = this.CellText.IndexOf(term, 0);
if (index >= 0)
{
// Create a smart tag token and a property bag for the
// recognized term.
ISmartTagProperties propertyBag =
site.GetNewPropertyBag();
// Write a new property value.
string key = "Key1";
propertyBag.Write(key, DateTime.Now.ToString());
// Attach the smart tag to the term in the document
this.PersistTag(propertyBag);
// This implementation only finds the first instance
// of a smart tag term in the cell.
break;
}
}
}
Berechtigungen
- Volle Vertrauenswürdigkeit für den unmittelbaren Aufrufer. Dieser Member kann von nur teilweise vertrauenswürdigem Code nicht verwendet werden. Weitere Informationen finden Sie unter Verwenden von Bibliotheken aus teilweise vertrauenswürdigem Code.