在GridWeb工作表的单元格中输入百分比格式的数据
Contents
[
Hide
]
可能的使用场景
GridWeb现在支持用户以百分比格式(如3%)输入单元格数据,并且单元格中的数据将自动格式为3.00%。但是,您必须将单元格样式设置为百分比格式,即GridTableItemStyle.NumberType为9或10。数字9将以3%的格式显示,但数字10将以3.00%的格式显示。
如果未将单元格样式设置为百分比格式,则输入数据3%将显示为0.03。
在GridWeb工作表的单元格中输入百分比格式的数据
以下示例代码将单元格A1的GridTableItemStyle.NumberType设置为10,因此输入的3%数据将自动格式为3.00%,如屏幕截图所示。
示例代码
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
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); | |