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:

  1. Herhangi bir hücreye sağ tıklayın.
  2. 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.

Aspose.Cells bir sınıf sağlar,Çalışma kitabı bu bir Microsoft Excel dosyasını temsil eder. buÇalışma kitabı sınıf bir içerirçalışma sayfaları Excel dosyasındaki her çalışma sayfasına erişim sağlayan koleksiyon. Bir çalışma sayfası şununla temsil edilir:Çalışma kağıdı sınıf. buÇalışma kağıdı sınıf bir sağlarCells Toplamak. İçindeki her öğeCells koleksiyon bir nesneyi temsil ederCellsınıf.

Aspose.Cells sağlarStil Al veSetStyle için yöntemlerCell sınıf. Bu yöntemler, bir hücrenin biçimlendirmesini almak ve ayarlamak için kullanılır. bustilclass, sayıların ve tarihlerin görüntü biçimleriyle ilgilenmek için bazı yararlı özellikler sağlar.

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. Bu yerleşik sayı biçimleri kullanılarak uygulanabilir.Sayı mülkiyetistil nesne. Tüm yerleşik sayı biçimlerine benzersiz sayısal değerler verilir. Geliştiriciler, istenen herhangi bir sayısal değeri atayabilir.Sayı mülkiyetistilgö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 @
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Create directory if it is not already present.
bool IsExists = System.IO.Directory.Exists(dataDir);
if (!IsExists)
System.IO.Directory.CreateDirectory(dataDir);
// Instantiating a Workbook object
Workbook workbook = new Workbook();
// Obtaining the reference of first worksheet
Worksheet worksheet = workbook.Worksheets[0];
// Adding the current system date to "A1" cell
worksheet.Cells["A1"].PutValue(DateTime.Now);
// Getting the Style of the A1 Cell
Style style = worksheet.Cells["A1"].GetStyle();
// Setting the display format to number 15 to show date as "d-mmm-yy"
style.Number = 15;
// Applying the style to the A1 cell
worksheet.Cells["A1"].SetStyle(style);
// Adding a numeric value to "A2" cell
worksheet.Cells["A2"].PutValue(20);
// Getting the Style of the A2 Cell
style = worksheet.Cells["A2"].GetStyle();
// Setting the display format to number 9 to show value as percentage
style.Number = 9;
// Applying the style to the A2 cell
worksheet.Cells["A2"].SetStyle(style);
// Adding a numeric value to "A3" cell
worksheet.Cells["A3"].PutValue(2546);
// Getting the Style of the A3 Cell
style = worksheet.Cells["A3"].GetStyle();
// Setting the display format to number 6 to show value as currency
style.Number = 6;
// Applying the style to the A3 cell
worksheet.Cells["A3"].SetStyle(style);
// Saving the Excel file
workbook.Save(dataDir + "book1.out.xls", SaveFormat.Excel97To2003);

Özel Sayı Biçimlerini Kullanma

Görüntüleme biçimini ayarlamak üzere kendi özelleştirilmiş biçim dizinizi tanımlamak içinstil nesneninGelenekEmlak. Bu yaklaşım önceden ayarlanmış biçimleri kullanmak kadar hızlı değildir ancak daha esnektir.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Create directory if it is not already present.
bool IsExists = System.IO.Directory.Exists(dataDir);
if (!IsExists)
System.IO.Directory.CreateDirectory(dataDir);
// Instantiating a Workbook object
Workbook workbook = new Workbook();
// Adding a new worksheet to the Excel object
int i = workbook.Worksheets.Add();
// Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.Worksheets[i];
// Adding the current system date to "A1" cell
worksheet.Cells["A1"].PutValue(DateTime.Now);
// Getting the style of A1 cell
Style style = worksheet.Cells["A1"].GetStyle();
// Setting the custom display format to show date as "d-mmm-yy"
style.Custom = "d-mmm-yy";
// Applying the style to A1 cell
worksheet.Cells["A1"].SetStyle(style);
// Adding a numeric value to "A2" cell
worksheet.Cells["A2"].PutValue(20);
// Getting the style of A2 cell
style = worksheet.Cells["A2"].GetStyle();
// Setting the custom display format to show value as percentage
style.Custom = "0.0%";
// Applying the style to A2 cell
worksheet.Cells["A2"].SetStyle(style);
// Adding a numeric value to "A3" cell
worksheet.Cells["A3"].PutValue(2546);
// Getting the style of A3 cell
style = worksheet.Cells["A3"].GetStyle();
// Setting the custom display format to show value as currency
style.Custom = "£#,##0;[Red]$-#,##0";
// Applying the style to A3 cell
worksheet.Cells["A3"].SetStyle(style);
// Saving the Excel file
workbook.Save(dataDir + "book1.out.xls", SaveFormat.Excel97To2003);

ileri konular