指定使用DBNum自定义模式格式
Contents
[
Hide
]
可能的使用场景
Aspose.Cells 支持 DBNum 自定义模式格式。例如,如果您的单元格值为 123,并且您将其自定义格式指定为 [DBNum2][$-804]General,则它将显示为 壹佰贰拾叁。您可以使用 Cell.getStyle() 和 Style.setCustom() 方法指定单元格的自定义格式。
示例代码
以下示例代码说明了如何指定DBNum自定义模式格式。请检查其output PDF了解更多帮助。
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 | |
// The path to the documents directory. | |
String dataDir = Utils.getSharedDataDir(SpecifyingDBNumCustomPatternFormatting.class) + "data/"; | |
//Create a workbook. | |
Workbook wb = new Workbook(); | |
//Access first worksheet. | |
Worksheet ws = wb.getWorksheets().get(0); | |
//Access cell A1 and put value 123. | |
Cell cell = ws.getCells().get("A1"); | |
cell.putValue(123); | |
//Access cell style. | |
Style st = cell.getStyle(); | |
//Specifying DBNum custom pattern formatting. | |
st.setCustom("[DBNum2][$-804]General"); | |
//Set the cell style. | |
cell.setStyle(st); | |
//Set the first column width. | |
ws.getCells().setColumnWidth(0, 30); | |
//Save the workbook in output pdf format. | |
wb.save(dataDir + "outputDBNumCustomFormatting.pdf", SaveFormat.PDF); |