Font Ayarları
Font Ayarlarını Yapılandırma
Aspose.Cells, bir Microsoft Excel dosyasını temsil eden Workbook adlı bir sınıf sağlar. Workbook sınıfı, bir Microsoft Excel dosyasındaki her bir çalışma sayfasına erişim sağlayan bir Worksheets koleksiyonunu içerir. Bir çalışma sayfası, Worksheet sınıfı tarafından temsil edilir. Worksheet sınıfı bir Cells koleksiyonu sağlar. Cells koleksiyonundaki her öğe, Cell sınıfının bir nesnesini temsil eder.
Aspose.Cells, Cell sınıfının GetStyle ve SetStyle yöntemlerini sağlar; bu yöntemler bir hücrenin biçimlendirme stiline getirilip alınmasında kullanılır. Style sınıfı, font ayarlarını yapılandırmak için özellikler sağlar.
Yazı Tipi Adını Ayarlama
Geliştiriciler, Style.Font nesnesinin Adı özelliğini kullanarak bir hücre içindeki metne herhangi bir font uygulayabilirler.
// 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]; | |
// Accessing the "A1" cell from the worksheet | |
Aspose.Cells.Cell cell = worksheet.Cells["A1"]; | |
// Adding some value to the "A1" cell | |
cell.PutValue("Hello Aspose!"); | |
// Obtaining the style of the cell | |
Style style = cell.GetStyle(); | |
// Setting the font name to "Times New Roman" | |
style.Font.Name = "Times New Roman"; | |
// Applying the style to the cell | |
cell.SetStyle(style); | |
// Saving the Excel file | |
workbook.Save(dataDir + "book1.out.xls", SaveFormat.Excel97To2003); |
Yazı Tipi Stilini Kalın Yapma
Geliştiriciler, metni kalın yapmak için Style.Font nesnesinin IsBold özelliğini true olarak ayarlayarak yapabilirler.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// 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]; | |
// Accessing the "A1" cell from the worksheet | |
Aspose.Cells.Cell cell = worksheet.Cells["A1"]; | |
// Adding some value to the "A1" cell | |
cell.PutValue("Hello Aspose!"); | |
// Obtaining the style of the cell | |
Style style = cell.GetStyle(); | |
// Setting the font weight to bold | |
style.Font.IsBold = true; | |
// Applying the style to the cell | |
cell.SetStyle(style); | |
// Saving the Excel file | |
workbook.Save("out.xlsx"); | |
Yazı Tipi Boyutunu Ayarlama
Style.Font nesnesinin Size özelliği ile yazı tipi boyutunu ayarlayın.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// 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]; | |
// Accessing the "A1" cell from the worksheet | |
Aspose.Cells.Cell cell = worksheet.Cells["A1"]; | |
// Adding some value to the "A1" cell | |
cell.PutValue("Hello Aspose!"); | |
// Obtaining the style of the cell | |
Style style = cell.GetStyle(); | |
// Setting the font size to 14 | |
style.Font.Size = 14; | |
// Applying the style to the cell | |
cell.SetStyle(style); | |
// Saving the Excel file | |
workbook.Save("out.xlsx"); | |
Yazı Tipi Rengini Ayarlama
Style.Font nesnesinin Color özelliğini kullanarak yazı tipi rengini ayarlayın. Renk numaralandırmasından ( .NET framework’ün bir parçası) herhangi bir rengi seçin ve Color özelliğine atayın.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// 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]; | |
// Accessing the "A1" cell from the worksheet | |
Aspose.Cells.Cell cell = worksheet.Cells["A1"]; | |
// Adding some value to the "A1" cell | |
cell.PutValue("Hello Aspose!"); | |
// Obtaining the style of the cell | |
Style style = cell.GetStyle(); | |
// Setting the font color to blue | |
style.Font.Color = Color.Blue; | |
// Applying the style to the cell | |
cell.SetStyle(style); | |
// Saving the Excel file | |
workbook.Save("out.xlsx"); | |
Yazı Tipi Altı Çizgi Türünü Ayarlama
Style.Font nesnesinin Underline özelliğini kullanarak metni altı çizili yapın. Aspose.Cells, FontUnderlineType numaralandırmasında çeşitli önceden tanımlanmış yazı tipi altı çizgi tipleri sunar.
Yazı Tipi Altı Çizgi Tipleri | Açıklama |
---|---|
Accounting | Tek hesap çizgisi |
Double | Çift çizgi |
DoubleAccounting | Çift hesap çizgisi |
None | Çizgi yok |
Single | Tek çizgi |
// 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]; | |
// Accessing the "A1" cell from the worksheet | |
Aspose.Cells.Cell cell = worksheet.Cells["A1"]; | |
// Adding some value to the "A1" cell | |
cell.PutValue("Hello Aspose!"); | |
// Obtaining the style of the cell | |
Style style = cell.GetStyle(); | |
// Setting the font to be underlined | |
style.Font.Underline = FontUnderlineType.Single; | |
// Applying the style to the cell | |
cell.SetStyle(style); | |
// Saving the Excel file | |
workbook.Save(dataDir + "out.xlsx"); |
Üstü Çizili Etkiyi Ayarlama
Üstü çizili uygulamak için Style.Font nesnesinin IsStrikeout özelliğini true olarak ayarlayın.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// 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]; | |
// Accessing the "A1" cell from the worksheet | |
Aspose.Cells.Cell cell = worksheet.Cells["A1"]; | |
// Adding some value to the "A1" cell | |
cell.PutValue("Hello Aspose!"); | |
// Obtaining the style of the cell | |
Style style = cell.GetStyle(); | |
// Setting the strike out effect on the font | |
style.Font.IsStrikeout = true; | |
// Applying the style to the cell | |
cell.SetStyle(style); | |
// Saving the Excel file | |
workbook.Save(dataDir + "out.xlsx"); |
Üst Simge Etkisini Ayarlama
Abone simgesini ayarlayarak Style.Font nesnesinin IsSubScript özelliğini true olarak ayarlayın.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// 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]; | |
// Accessing the "A1" cell from the worksheet | |
Aspose.Cells.Cell cell = worksheet.Cells["A1"]; | |
// Adding some value to the "A1" cell | |
cell.PutValue("Hello Aspose!"); | |
// Obtaining the style of the cell | |
Style style = cell.GetStyle(); | |
// Setting subscript effect | |
style.Font.IsSubscript = true; | |
// Applying the style to the cell | |
cell.SetStyle(style); | |
// Saving the Excel file | |
workbook.Save(dataDir + "out.xlsx"); | |
Yazı Tipi Üzerine Üst Simge Efekti Ayarlama
Geliştiriciler, yazı tipi üzerine üst simge efektini IsSuperscript öğesinin Style.Font özelliğini true olarak ayarlayarak uygulayabilirler.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// 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]; | |
// Accessing the "A1" cell from the worksheet | |
Aspose.Cells.Cell cell = worksheet.Cells["A1"]; | |
// Adding some value to the "A1" cell | |
cell.PutValue("Hello Aspose!"); | |
// Obtaining the style of the cell | |
Style style = cell.GetStyle(); | |
// Setting superscript effect | |
style.Font.IsSuperscript = true; | |
// Applying the style to the cell | |
cell.SetStyle(style); | |
// Saving the Excel file | |
workbook.Save(dataDir + "out.xlsx"); |