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