Stil.Custom Özelliğini Ayarlarken Özel Sayı Biçimini Kontrol Edin
Olası Kullanım Senaryoları
Eğer Style.custom özelliğine geçersiz bir özel sayı biçimi atamışsanız, Aspose.Cells herhangi bir istisna fırlatmaz. Ancak Aspose.Cells’ın atanan özel sayı biçiminin geçerli olup olmadığını kontrol etmesini istiyorsanız, lütfen Workbook.settings.check_custom_number_format özelliğini true olarak ayarlayın.
Stil.Custom özelliğini ayarladığınızda özel sayı biçimine geçersiz bir özel sayı biçimi atayan aşağıdaki örnek kod. {1} özelliğini zaten true olarak ayarladığımız için, bu nedenle Geçersiz özel sayı biçimi gibi bir istisna fırlatır. Daha fazla yardım için kodun içindeki yorumları okuyun.
Aşağıdaki örnek kod, Style.custom özelliğine geçersiz özel bir sayı biçimi atar. Workbook.settings.check_custom_number_format özelliğini zaten true olarak ayarladığımız için, bunun sonucunda geçersiz sayı biçimi gibi bir istisna fırlatır. Daha fazla yardım için kod içindeki yorumları okuyun.
Örnek Kod
from aspose.cells import Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Create an instance of Workbook class | |
book = 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.settings.check_custom_number_format = True | |
# Access first worksheet | |
sheet = book.worksheets[0] | |
# Access cell A1 and put some number to it | |
cell = sheet.cells.get("A1") | |
cell.put_value(2347) | |
# Access cell's style and set its Style.Custom property | |
style = cell.get_style() | |
# This line will throw exception if Workbook.Settings.CheckCustomNumberFormat is set to true | |
style.custom = "ggg @ fff" |