Hizalama Ayarları
Hizalama Ayarlarını Yapılandırma
Microsoft Excel’deki hizalama ayarları
Hücreleri biçimlendirmek için Microsoft Excel’i kullanan herkes, Microsoft Excel’deki hizalama ayarlarına aşina olacaktır.
Yukarıdaki şekilde görebileceğiniz gibi, farklı hizalama seçenekleri vardır:
- Metin hizalama (yatay ve dikey)
- Girinti.
- Oryantasyon.
- Metin kontrolü.
- Metin yönü.
Bu hizalama ayarlarının tümü Aspose.Cells tarafından tam olarak desteklenmektedir ve aşağıda daha ayrıntılı olarak ele alınmıştır.
Aspose.Cells’deki hizalama ayarları
Aspose.Cells sağlarStil Al veSetStyle için yöntemlerCell bir hücrenin biçimlendirmesini almak ve ayarlamak için kullanılan sınıf. bustilclass, hizalama ayarlarını yapılandırmak için yararlı özellikler sağlar.
kullanarak herhangi bir metin hizalama türünü seçin.Metin Hizalama Türü numaralandırma. Ön tanımlı metin hizalama türleriMetin Hizalama Türünumaralandırma şunlardır:
Metin Hizalama Türleri | Açıklama |
---|---|
Alt kısım | Alt metin hizalamasını temsil eder |
merkez | Merkez metin hizalamasını temsil eder |
Merkez Boyunca | Metin hizalaması boyunca merkezi temsil eder |
dağıtılmış | Dağıtılmış metin hizalamasını temsil eder |
Doldurmak | Dolgu metni hizalamasını temsil eder |
Genel | Genel metin hizalamasını temsil eder |
Savunmak | Yaslanmış metin hizalamasını temsil eder |
Sol | Sola metin hizalamasını temsil eder |
Doğru | Doğru metin hizalamasını temsil eder |
Tepe | Üst metin hizalamasını temsil eder |
GerekçelendirilmişDüşük | Metni, Arapça metin için ayarlanmış bir kashida uzunluğuyla hizalar. |
Tayland Dağıtılmış | Tayca metni özellikle dağıtır, çünkü her karakter bir kelime olarak ele alınır. |
Yatay, Dikey Hizalama ve Girinti
KullanYatay hizalama metni yatay olarak hizalama özelliği veDikey hizalamaMetni dikey olarak hizalama özelliği. Bir hücredeki metnin girinti düzeyini ayarlamak mümkündür.Girinti Düzeyi Emlak ve tt yalnızca Yatay hizalama sola veya sağa olduğunda etkilidir.
// Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
// Obtaining the reference of first worksheet | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
// Accessing the "A1" cell from the worksheet | |
Cell cell = worksheet.getCells().get("A1"); | |
// Adding some value to the "A1" cell | |
cell.putValue("Visit Aspose!"); | |
// Setting the horizontal alignment of the text in the "A1" cell | |
Style style = cell.getStyle(); | |
//Set text left horizontal alignment | |
style.setHorizontalAlignment(TextAlignmentType.RIGHT); | |
//Set indent | |
style.setIndentLevel(4); | |
//Set text top vertical alignment | |
style.setVerticalAlignment(TextAlignmentType.TOP); | |
cell.setStyle(style); | |
// Saving the Excel file | |
workbook.save("book1.xlsx"); |
Oryantasyon
ile bir hücredeki metnin yönünü (döndürme) ayarlayın.Dönüş açısıEmlak.
// Accessing the "A1" cell from the worksheet | |
Cell cell = worksheet.getCells().get("A1"); | |
// Adding some value to the "A1" cell | |
cell.putValue("Visit Aspose!"); | |
// Setting the horizontal alignment of the text in the "A1" cell | |
Style style = cell.getStyle(); | |
// Setting the rotation of the text (inside the cell) to 25 | |
style.setRotationAngle(25); | |
cell.setStyle(style); | |
//Accessing the "A2" cell from the worksheet | |
cell = worksheet.getCells().get("A2"); | |
// Adding some value to the "A1" cell | |
cell.putValue("Visit Aspose!"); | |
// Setting the horizontal alignment of the text in the "A2" cell | |
style = cell.getStyle(); | |
// Setting the orientation of the text from top to bottom | |
style.setRotationAngle(255); | |
cell.setStyle(style); | |
// Saving the Excel file | |
workbook.save("book1.xlsx"); |
Metin Kontrolü
Aşağıdaki bölümde, metin kaydırma, sığdırmak için küçültme ve diğer biçimlendirme seçeneklerini ayarlayarak metnin nasıl kontrol edileceği anlatılmaktadır.
Metni Kaydırma
Metni bir hücreye kaydırmak okumayı kolaylaştırır: Hücrenin yüksekliği, onu kesmek veya bitişik hücrelere dökmek yerine tüm metne sığacak şekilde ayarlanır. ile metin kaydırmayı açık veya kapalı olarak ayarlayın.metin sarılmış mıEmlak.
// Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
// Obtaining the reference of first worksheet | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
// Accessing the "A1" cell from the worksheet | |
Cell cell = worksheet.getCells().get("A1"); | |
// Adding some value to the "A1" cell | |
cell.putValue("I am using the latest version of Aspose.Cells to test this functionality."); | |
// Gets style | |
Style style = cell.getStyle(); | |
// Wrap Cell's Text wrap | |
style.setTextWrapped( true); | |
//Set style. | |
cell.setStyle(style); | |
// Saving the Excel file | |
workbook.save("book1.xlsx"); |
Sığdırmak İçin Küçültmek
Metni bir alana kaydırma seçeneği, metin boyutunu bir hücrenin boyutlarına sığacak şekilde küçültmektir. Bu ayarlanarak yapılır.Sığdırmak için küçültmek Emlak. iledoğru.
// Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
// Obtaining the reference of first worksheet | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
// Accessing the "A1" cell from the worksheet | |
Cell cell = worksheet.getCells().get("A1"); | |
// Adding some value to the "A1" cell | |
cell.putValue("I am using the latest version of Aspose.Cells to test this functionality."); | |
// Gets style in the "A1" cell | |
Style style = cell.getStyle(); | |
// Shrinking the text to fit according to the dimensions of the cell | |
style.setShrinkToFit(true); | |
cell.setStyle(style); | |
// Saving the Excel file | |
workbook.save("book1.xlsx"); | |
Birleştirme Cells
Microsoft Excel gibi, Aspose.Cells de birkaç hücrenin tek hücrede birleştirilmesini destekler. Aspose.Cells, bu görev için iki yaklaşım sağlar. Bunun bir yolu,Birleştirmek yöntem. Yöntem, hücreleri birleştirmek için aşağıdaki parametreleri alır:
- İlk satır: Birleştirmenin başlayacağı ilk satır.
- İlk sütun: birleştirmeye başlayacağınız ilk sütun.
- Satır sayısı: birleştirilecek satır sayısı.
- Sütun sayısı: birleştirilecek sütun sayısı.
// Create a Cells object ot fetch all the cells. | |
Cells cells = worksheet.getCells(); | |
// Merge some Cells (C6:E7) into a single C6 Cell. | |
cells.merge(5, 2, 2, 3); | |
// Input data into C6 Cell. | |
worksheet.getCells().get(5, 2).putValue("This is my value"); | |
// Create a Style object to fetch the Style of C6 Cell. | |
Style style = worksheet.getCells().get(5, 2).getStyle(); | |
// Create a Font object | |
Font font = style.getFont(); | |
// Set the name. | |
font.setName("Times New Roman"); | |
// Set the font size. | |
font.setSize(18); | |
// Set the font color | |
font.setColor(Color.getBlue()); | |
// Bold the text | |
font.setBold(true); | |
// Make it italic | |
font.setItalic(true); | |
// Set the backgrond color of C6 Cell to Red | |
style.setForegroundColor(Color.getRed()); | |
style.setPattern(BackgroundType.SOLID); | |
// Apply the Style to C6 Cell. | |
cells.get(5, 2).setStyle(style); | |
Metin yönü
Hücrelerdeki metnin okuma sırasını ayarlamak mümkündür. Okuma sırası, karakterlerin, kelimelerin vb. görüntülendiği görsel sıradır. Örneğin, İngilizce soldan sağa bir dilken, Arapça sağdan sola bir dildir.
Okuma sırası ile ayarlanırMetin yönü Emlak. Aspose.Cells, önceden tanımlanmış metin yönü türleri sağlar.Metin Yönü Türünumaralandırma.
Metin Yönü Türleri | Açıklama |
---|---|
Bağlam | İlk girilen karakterin diliyle tutarlı okuma sırası |
Soldan sağa | Soldan sağa okuma sırası |
Sağdan sola | Sağdan sola okuma sırası |
// Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
// Obtaining the reference of first worksheet | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
// Accessing the "A1" cell from the worksheet | |
Cell cell = worksheet.getCells().get("A1"); | |
// Adding some value to the "A1" cell | |
cell.putValue("I am using the latest version of Aspose.Cells to test this functionality."); | |
// Gets style in the "A1" cell | |
Style style = cell.getStyle(); | |
// Shrinking the text to fit according to the dimensions of the cell | |
style.setTextDirection(TextDirectionType.LEFT_TO_RIGHT); | |
cell.setStyle(style); | |
// Saving the Excel file | |
workbook.save("book1.xlsx"); |