Immettere i dati Cell del foglio di lavoro GridWeb in formato percentuale
Contents
[
Hide
]
Possibili scenari di utilizzo
GridWeb ora supporta gli utenti per inserire i dati della cella in formato percentuale come 3% e i dati nella cella verranno formattati automaticamente come 3,00%. Tuttavia, dovrai impostare lo stile della cella su Percentage Format che è GridTableItemStyle.NumberType a 9 o 10. Il numero 9 formatterà il 3% come 3% ma il numero 10 formatterà il 3% come 3,00%.
Se non hai impostato lo stile della cella su Formato percentuale, i dati di input 3% verranno visualizzati come 0,03.
Immettere i dati Cell del foglio di lavoro GridWeb in formato percentuale
Il seguente codice di esempio imposta la cella A1 GridTableItemStyle.NumberType come 10, pertanto i dati di input 3% vengono automaticamente formattati come 3,00% come mostrato nello screenshot.
Codice d’esempio
This file contains hidden or 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
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
//Access cell A1 of first gridweb worksheet | |
GridCell cellA1 = gridweb.getWorkSheets().get(0).getCells().get("A1"); | |
//Access cell style and set its number format to 10 which is a Percentage 0.00% format | |
GridTableItemStyle st = cellA1.getStyle(); | |
st.setNumberType(10); | |
cellA1.setStyle(st); | |