Stil.Custom Özelliğini Ayarlarken Özel Sayı Biçimini Kontrol Edin
Olası Kullanım Senaryoları
Geçersiz özel sayı biçimi Style.setCustom(string) yöntemine atanırsa, Aspose.Cells for Node.js via C++ herhangi bir istisna atmaz. Ancak, Aspose.Cells’in atanan özel sayı biçiminin geçerli olup olmadığını kontrol etmesini istiyorsanız, lütfen Workbook.getSettings().setCheckCustomNumberFormat(boolean) yöntemini doğru olarak ayarlayın.
Style.setCustom(string) yöntemini ayarlarken Özel Sayı Biçimini Kontrol Edin
Aşağıdaki örnek kod, Style.setCustom(string) yöntemine geçersiz bir özel sayı biçimi atar. Zaten Workbook.getSettings().setCheckCustomNumberFormat(boolean) yöntemini doğru olarak ayarladığımızdan, bir istisna fırlatır, örn., Geçersiz sayı biçimi. Daha fazla yardım için kod içindeki yorumları okuyun.
Örnek Kod
const path = require("path"); | |
const AsposeCells = require("aspose.cells.node"); | |
// Create an instance of Workbook class | |
const book = new AsposeCells.Workbook(); | |
// Setting this property to true will make Aspose.Cells to throw exception | |
// when invalid custom number format is assigned to Style.Custom property | |
book.getSettings().setCheckCustomNumberFormat(true); | |
// Access first worksheet | |
const sheet = book.getWorksheets().get(0); | |
// Access cell A1 and put some number to it | |
const cell = sheet.getCells().get("A1"); | |
cell.putValue(2347); | |
// Access cell's style and set its Style.Custom property | |
const style = cell.getStyle(); | |
// This line will throw exception if Workbook.Settings.CheckCustomNumberFormat is set to true | |
style.setCustom("ggg @ fff"); //Invalid custom number format |