DBNum Özel Kalıp Biçimlendirmesini Belirleme

Olası Kullanım Senaryoları

Aspose.Cells desteklerDBNumözel desen biçimlendirme. Örneğin, hücre değeriniz 123 ise ve özel biçimlendirmesini [DBNum2][$-804]General olarak belirtirseniz, 壹佰贰拾叁 gibi görüntülenecektir. Kullanarak hücrenin özel biçimlendirmesini belirleyebilirsiniz.Cell.getStyle() veStyle.setCustom()yöntemler.

Basit kod

Aşağıdaki örnek kod, nasıl belirtileceğini gösterirDBNumözel desen biçimlendirme. Lütfen kontrol edinçıkış PDF daha fazla yardım için

// 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);