Узнайте, начинается ли значение ячейки с одинарной кавычки через Aspose.Cells для API Python via .NET.
Contents
[
Hide
]
Теперь Aspose.Cells предоставляет свойство Style.QuotePrefix для определения, начинается ли значение ячейки с одинарной кавычки. До появления этого свойства не было способа различить строки, такие как образец и ‘образец и т. д.
Определите, начинается ли значение ячейки с одинарной кавычки
В следующем примере кода объясняется, что строки, такие как образец и ‘образец, не могут быть отличены с помощью свойства Cell.StringValue. Поэтому мы должны использовать свойство Style.QuotePrefix для их различения.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Create an instance of workbook | |
Workbook workbook = new Workbook(); | |
//Access first worksheet from the collection | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
//Access cells A1 and A2 | |
Cell a1 = worksheet.getCells().get("A1"); | |
Cell a2 = worksheet.getCells().get("A2"); | |
//Add simple text to cell A1 and text with quote prefix to cell A2 | |
a1.putValue("sample"); | |
a2.putValue("'sample"); | |
//Print their string values, A1 and A2 both are same | |
System.out.println("String value of A1: " + a1.getStringValue()); | |
System.out.println("String value of A2: " + a2.getStringValue()); | |
//Access styles of cells A1 and A2 | |
Style s1 = a1.getStyle(); | |
Style s2 = a2.getStyle(); | |
System.out.println(); | |
//Check if A1 and A2 has a quote prefix | |
System.out.println("A1 has a quote prefix: " + s1.getQuotePrefix()); | |
System.out.println("A2 has a quote prefix: " + s2.getQuotePrefix()); |