Conserva il prefisso apice singolo del valore della cella o dell intervallo
Possibili Scenari di Utilizzo
Quando si inserisce un valore dentro la cella che ha un apice iniziale o un simbolo di apice singolo, Microsoft Excel lo nasconde, ma quando si seleziona la cella, visualizza il prefisso apice in un formula bar come mostrato nella seguente schermata.
Anche Aspose.Cells per Python via .NET nasconde il prefisso apice o l’apice singolo come Microsoft Excel ma imposta il Style.quote_prefix come vero per quella cella. Se si imposta uno stile vuoto della cella, allora Style.quote_prefix diventa di nuovo falso. Per risolvere questo problema, Aspose.Cells per Python via .NET fornisce la proprietà Style.quote_prefix, quando è impostata a falso, quindi Style.quote_prefix non viene affatto aggiornato e il suo vecchio valore è preservato. Significa che se il vecchio valore della proprietà Style.quote_prefix era vero, rimarrà vero e se il vecchio valore era falso, rimarrà falso.
Conserva il prefisso apice singolo del valore della cella o dell’intervallo
Il seguente codice di esempio spiega l’uso della proprietà Style.quote_prefix come descritto in precedenza. Si prega di leggere i commenti all’interno del codice e di vedere l’output della console del codice sottostante per ulteriore aiuto.
Codice di Esempio
from aspose.cells import StyleFlag, Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Create workbook | |
wb = Workbook() | |
# Access first worksheet | |
ws = wb.worksheets[0] | |
# Access cell A1 | |
cell = ws.cells.get("A1") | |
# Put some text in cell, it does not have Single Quote at the beginning | |
cell.put_value("Text") | |
# Access style of cell A1 | |
st = cell.get_style() | |
# Print the value of Style.quote_prefix of cell A1 | |
print("Quote Prefix of Cell A1: " + str(st.quote_prefix)) | |
# Put some text in cell, it has Single Quote at the beginning | |
cell.put_value("'Text") | |
# Access style of cell A1 | |
st = cell.get_style() | |
# Print the value of Style.quote_prefix of cell A1 | |
print("Quote Prefix of Cell A1: " + str(st.quote_prefix)) | |
# Print information about StyleFlag.quote_prefix property | |
print() | |
print("When StyleFlag.quote_prefix is False, it means, do not update the value of Cell.Style.quote_prefix.") | |
print("Similarly, when StyleFlag.quote_prefix is True, it means, update the value of Cell.Style.quote_prefix.") | |
print() | |
# Create an empty style | |
st = wb.create_style() | |
# Create style flag - set StyleFlag.quote_prefix as false | |
# It means, we do not want to update the Style.quote_prefix property of cell A1's style. | |
flag = StyleFlag() | |
flag.quote_prefix = False | |
# Create a range consisting of single cell A1 | |
rng = ws.cells.create_range("A1") | |
# Apply the style to the range | |
rng.apply_style(st, flag) | |
# Access the style of cell A1 | |
st = cell.get_style() | |
# Print the value of Style.quote_prefix of cell A1 | |
# It will print True, because we have not updated the Style.quote_prefix property of cell A1's style. | |
print("Quote Prefix of Cell A1: " + str(st.quote_prefix)) | |
# Create an empty style | |
st = wb.create_style() | |
# Create style flag - set StyleFlag.quote_prefix as true | |
# It means, we want to update the Style.quote_prefix property of cell A1's style. | |
flag = StyleFlag() | |
flag.quote_prefix = True | |
# Apply the style to the range | |
rng.apply_style(st, flag) | |
# Access the style of cell A1 | |
st = cell.get_style() | |
# Print the value of Style.quote_prefix of cell A1 | |
# It will print False, because we have updated the Style.quote_prefix property of cell A1's style. | |
print("Quote Prefix of Cell A1: " + str(st.quote_prefix)) |
Output della console
Quote Prefix of Cell A1: False
Quote Prefix of Cell A1: True
When StyleFlag.quote_prefix is False, it means, do not update the value of Cell.Style.quote_prefix.
Similarly, when StyleFlag.quote_prefix is True, it means, update the value of Cell.Style.quote_prefix.
Quote Prefix of Cell A1: True
Quote Prefix of Cell A1: False