Sayı Ayarları
Numbers ve Tarihlerin Görüntüleme Biçimlerini Ayarlama
Microsoft Excel’in çok güçlü bir özelliği, kullanıcıların sayısal değerlerin ve tarihlerin görüntülenme biçimlerini ayarlamasına izin vermesidir. Sayısal verilerin ondalık, para birimi, yüzde, kesir veya muhasebe değerleri gibi farklı değerleri temsil etmek için kullanılabileceğini biliyoruz. Tüm bu sayısal değerler, temsil ettikleri bilgi türüne bağlı olarak farklı biçimlerde görüntülenir. Benzer şekilde, tarih veya saatin görüntülenebileceği birçok biçim vardır. Aspose.Cells, bu işlevi destekler ve geliştiricilerin bir sayı veya tarih için herhangi bir görüntüleme formatı ayarlamasına izin verir.
Microsoft Excel’de Görüntü Biçimlerini Ayarlama
Microsoft Excel’de görüntüleme biçimlerini ayarlamak için:
- Herhangi bir hücreye sağ tıklayın.
- SeçmeBiçim Cells. Herhangi bir değer türünün görüntü formatlarını ayarlamak için kullanılan bir iletişim kutusu görünecektir.
İletişim kutusunun sol tarafında, aşağıdakiler gibi birçok değer kategorisi vardır:Genel, Sayı, Para birimi, Muhasebe, Tarih, Zaman, **Yüzde,**vb. Aspose.Cells, bu görüntüleme biçimlerinin tümünü destekler.
Yerleşik Sayı Biçimlerini Kullanma
Aspose.Cells, sayıların ve tarihlerin görüntülenme biçimlerini yapılandırmak için bazı yerleşik sayı biçimleri sunar. Tüm yerleşik sayı biçimlerine benzersiz sayısal değerler verilir. Geliştiriciler, istenen herhangi bir sayısal değeri atayabilir.Sayı yöntemistil görüntüleme biçimini uygulamak için nesne. Bu yaklaşım hızlıdır. Aspose.Cells tarafından desteklenen yerleşik sayı biçimleri aşağıda listelenmiştir.
Değer | Tip | Dizeyi Biçimlendir |
---|---|---|
0 | Genel | Genel |
1 | Ondalık | 0 |
2 | Ondalık | 0.00 |
3 | Ondalık | # ,##0 |
4 | Ondalık | # ,##0.00 |
5 | Para birimi | $#,##0;$-#,##0 |
6 | Para birimi | $#,##0;[Kırmızı]$-#,##0 |
7 | Para birimi | $#,##0.00;$-#,##0.00 |
8 | Para birimi | $#,##0,00;[Kırmızı]$-#,##0,00 |
9 | Yüzde | 0% |
10 | Yüzde | 0.00% |
11 | İlmi | 0.00E+00 |
12 | kesir | # ?/? |
13 | kesir | # / |
14 | Tarih | a/g/yy |
15 | Tarih | g-aa-yy |
16 | Tarih | g-mmm |
17 | Tarih | mmm-yy |
18 | Zaman | s:dd AM/PM |
19 | Zaman | s:dd:ss AM/PM |
20 | Zaman | Hmm |
21 | Zaman | s:dd:ss |
22 | Zaman | aa/g/yy s:dd |
37 | Para birimi | # ,##0;-#,##0 |
38 | Para birimi | # ,##0;[Kırmızı]-#,##0 |
39 | Para birimi | # ,##0.00;-#,##0.00 |
40 | Para birimi | # ,##0,00;[Kırmızı]-#,##0,00 |
41 | Muhasebe | _ * #,##0_ ;_ * “_ ;_ @_ |
42 | Muhasebe | _ $* #,##0_ ;_ $* “_ ;_ @_ |
43 | Muhasebe | _ * #,##0.00_ ;_ * “??_ ;_ @_ |
44 | Muhasebe | _ $* #,##0.00_ ;_ $* “??_ ;_ @_ |
45 | Zaman | dd:ss |
46 | Zaman | sa :dd:ss |
47 | Zaman | mm:ss.0 |
48 | İlmi | ## 0.0E+00 |
49 | Metin | @ |
// Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
// Obtaining the reference of first worksheet | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
// Adding the current system date to "A1" cell | |
worksheet.getCells().get("A1").putValue(DateTime.getNow()); | |
// Getting the Style of the A1 Cell | |
Style style = worksheet.getCells().get("A1").getStyle(); | |
// Setting the display format to number 15 to show date as "d-mmm-yy" | |
style.setNumber(15); | |
// Applying the style to the A1 cell | |
worksheet.getCells().get("A1").setStyle(style); | |
// Adding a numeric value to "A2" cell | |
worksheet.getCells().get("A2").putValue(20); | |
// Getting the Style of the A2 Cell | |
style = worksheet.getCells().get("A2").getStyle(); | |
// Setting the display format to number 9 to show value as percentage | |
style.setNumber(9); | |
// Applying the style to the A2 cell | |
worksheet.getCells().get("A2").setStyle(style); | |
// Adding a numeric value to "A3" cell | |
worksheet.getCells().get("A3").putValue(2546); | |
// Getting the Style of the A3 Cell | |
style = worksheet.getCells().get("A3").getStyle(); | |
// Setting the display format to number 6 to show value as currency | |
style.setNumber(6); | |
// Applying the style to the A3 cell | |
worksheet.getCells().get("A3").setStyle(style); | |
// Saving the Excel file | |
workbook.save("book1.out.xls"); |
Özel Sayı Biçimlerini Kullanma
Görüntüleme biçimini ayarlamak üzere kendi özelleştirilmiş biçim dizinizi tanımlamak içinGelenek. Bu yaklaşım önceden ayarlanmış biçimleri kullanmak kadar hızlı değildir ancak daha esnektir.
// Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
// Obtaining the reference of first worksheet | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
// Adding the current system date to "A1" cell | |
worksheet.getCells().get("A1").putValue(DateTime.getNow()); | |
// Getting the Style of the A1 Cell | |
Style style = worksheet.getCells().get("A1").getStyle(); | |
// Setting the custom display format to show date as "d-mmm-yy" | |
style.setCustom("d-mmm-yy"); | |
// Applying the style to the A1 cell | |
worksheet.getCells().get("A1").setStyle(style); | |
// Adding a numeric value to "A2" cell | |
worksheet.getCells().get("A2").putValue(20); | |
// Getting the Style of the A2 Cell | |
style = worksheet.getCells().get("A2").getStyle(); | |
// Setting the custom display format to show value as percentage | |
style.setCustom("0.0%"); | |
// Applying the style to the A2 cell | |
worksheet.getCells().get("A2").setStyle(style); | |
// Adding a numeric value to "A3" cell | |
worksheet.getCells().get("A3").putValue(2546); | |
// Getting the Style of the A3 Cell | |
style = worksheet.getCells().get("A3").getStyle(); | |
// Setting the custom display format to show value as currency | |
style.setCustom( "£#,##0;[Red]$-#,##0"); | |
// Applying the style to the A3 cell | |
worksheet.getCells().get("A3").setStyle(style); | |
// Saving the Excel file | |
workbook.save("book1.out.xls"); |