Yazı Tipi Ayarlarıyla Başa Çıkma

Yazı Tipi Ayarlarını Yapılandırma

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 Sayfası Koleksiyonu Bu, bir Excel dosyasındaki her çalışma sayfasına erişim sağlar. 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 şunları sağlar:Cell sınıf'setStyle yöntemi, bir hücrenin biçimlendirmesini ayarlamak için kullanılır. Ayrıca, nesneninstilclass, yazı tipi ayarlarını yapılandırmak için özellikler sağlar.

Bu makale şunların nasıl yapılacağını gösterir:

Yazı Tipi Adını Ayarlama

Kullanarak hücrelerdeki metne belirli bir yazı tipi uygulayın.Yazı tipi nesneninsetNameEmlak.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// The path to the documents directory.
String dataDir = Utils.getSharedDataDir(SettingFontName.class) + "data/";
// Instantiating a Workbook object
Workbook workbook = new Workbook();
// Accessing the added worksheet in the Excel file
int sheetIndex = workbook.getWorksheets().add();
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex);
Cells cells = worksheet.getCells();
// Adding some value to the "A1" cell
Cell cell = cells.get("A1");
cell.setValue("Hello Aspose!");
// Setting the font name to "Times New Roman"
Style style = cell.getStyle();
Font font = style.getFont();
font.setName("Times New Roman");
cell.setStyle(style);
// Saving the modified Excel file in default format
workbook.save(dataDir + "SettingFontName_out.xls");

Yazı Tipi Stilini Kalın Olarak Ayarlama

ayarlayarak metni kalın olarak ayarlayın.Yazı tipi nesneninkalın ayarla mülkiyetdoğru.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// The path to the output directory.
String outputDir = Utils.Get_OutputDirectory();
// Instantiating a Workbook object
Workbook workbook = new Workbook();
// Adding a new worksheet to the Excel object
int i = workbook.getWorksheets().add();
// Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.getWorksheets().get(i);
// Accessing the "A1" cell from the worksheet
Cell cell = worksheet.getCells().get("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.getFont().setBold(true);
// Applying the style to the cell
cell.setStyle(style);
// Saving the Excel file
workbook.save(outputDir + "book1.out.xlsx", SaveFormat.XLSX);

Yazı Tipi Boyutunu Ayarlama

kullanarak yazı tipi boyutunu ayarlayın.Yazı tipi nesneninsetBoyutuEmlak.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// The path to the documents directory.
String dataDir = Utils.getSharedDataDir(SetFontSize.class) + "data/";
// Instantiating a Workbook object
Workbook workbook = new Workbook();
// Accessing the added worksheet in the Excel file
int sheetIndex = workbook.getWorksheets().add();
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex);
Cells cells = worksheet.getCells();
// Adding some value to the "A1" cell
Cell cell = cells.get("A1");
cell.setValue("Hello Aspose!");
// Setting the font weight to bold
Style style = cell.getStyle();
Font font = style.getFont();
font.setSize(14);
cell.setStyle(style);
cell.setStyle(style);
// Saving the modified Excel file in default format
workbook.save(dataDir + "SetFontSize_out.xls");

Yazı Tipi Altı Çizili Tipini Ayarlama

ile metnin altını çizinYazı tipi nesneninsetUnderline Emlak. Aspose.Cells, önceden tanımlanmış çeşitli alt çizgili yazı tipleri sunar.FontUnderlineTypenumaralandırma.

Alt Çizgi Tipleri Açıklama
YOK Alt çizgi yok
BEKAR Tek bir alt çizgi
ÇİFT Çift alt çizgi
MUHASEBE Tek bir muhasebe alt çizgisi
DOUBLE_ACCOUNTING Çift hesap altı çizili
DASH Kesikli Altı Çizili
DASH_NOKTA_DOT_AĞIR Kalın Çizgi-Nokta-Nokta Altı Çizili
DASH_NOKTA_AĞIR Kalın Çizgi-Nokta Altı Çizili
DASHED_AĞIR Kalın Kesikli Alt Çizgi
DASH_LONG Uzun Kesikli Alt Çizgi
DASH_UZUN_AĞIR Kalın Uzun Kesikli Alt Çizgi
DOT_DASH Tire-Nokta Altı Çizili
NOKTA_NOKTA_DASH Tire-Nokta-Nokta Altı Çizili
NOKTALI Noktalı Altı Çizili
DOTTED_AĞIR Kalın Noktalı Alt Çizgi
AĞIR Kalın Alt Çizgi
DALGA Dalga Alt Çizgisi
WAVY_DOUBLE Çift Dalga Alt Çizgi
dalgalı_ağır Ağır Dalga Alt Çizgisi
 SÖZLER Yalnızca Boşluk Olmayan Karakterlerin Altı Çizili
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// The path to the documents directory.
String dataDir = Utils.getSharedDataDir(SettingFontUnderlineType.class) + "data/";
// Instantiating a Workbook object
Workbook workbook = new Workbook();
// Accessing the added worksheet in the Excel file
int sheetIndex = workbook.getWorksheets().add();
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex);
Cells cells = worksheet.getCells();
// Adding some value to the "A1" cell
Cell cell = cells.get("A1");
cell.setValue("Hello Aspose!");
// Setting the font to be underlined
Style style = cell.getStyle();
Font font = style.getFont();
font.setUnderline(FontUnderlineType.SINGLE);
cell.setStyle(style);
cell.setStyle(style);
// Saving the modified Excel file in default format
workbook.save(dataDir + "SFUnderlineType_out.xls");

Yazı Tipi Rengini Ayarlama

ile yazı tipi rengini ayarlayın.Yazı tipi nesneninrenk ayarla Emlak. herhangi bir renk seçinRenk numaralandırın ve seçilen rengiYazı tipi nesneninrenk ayarla.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// The path to the documents directory.
String dataDir = Utils.getSharedDataDir(SetFontColor.class) + "data/";
// Instantiating a Workbook object
Workbook workbook = new Workbook();
// Accessing the added worksheet in the Excel file
int sheetIndex = workbook.getWorksheets().add();
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex);
Cells cells = worksheet.getCells();
// Adding some value to the "A1" cell
Cell cell = cells.get("A1");
cell.setValue("Hello Aspose!");
// Setting the font color to blue
Style style = cell.getStyle();
Font font = style.getFont();
font.setColor(Color.getBlue());
cell.setStyle(style);
cell.setStyle(style);
// Saving the modified Excel file in default format
workbook.save(dataDir + "SetFontColor_out.xls");

Metin Üzerinde Üstü Çizili Efekti Ayarlama

Üstü çizili metin ileYazı tipi nesneninsetStrikeoutEmlak.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// The path to the documents directory.
String dataDir = Utils.getSharedDataDir(SettingStrikeOutEffect.class) + "data/";
// Instantiating a Workbook object
Workbook workbook = new Workbook();
// Accessing the added worksheet in the Excel file
int sheetIndex = workbook.getWorksheets().add();
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex);
Cells cells = worksheet.getCells();
// Adding some value to the "A1" cell
Cell cell = cells.get("A1");
cell.setValue("Hello Aspose!");
// Setting the strike out effect on the font
Style style = cell.getStyle();
Font font = style.getFont();
font.setStrikeout(true);
cell.setStyle(style);

Aboneliği Ayarlama

Kullanarak metni üst simge yapınYazı tipi nesneninsetSubscriptEmlak.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// The path to the documents directory.
String dataDir = Utils.getSharedDataDir(SetSubscript.class) + "data/";
// Instantiating a Workbook object
Workbook workbook = new Workbook();
// Accessing the added worksheet in the Excel file
int sheetIndex = workbook.getWorksheets().add();
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex);
Cells cells = worksheet.getCells();
// Adding some value to the "A1" cell
Cell cell = cells.get("A1");
cell.setValue("Hello Aspose!");
// Setting subscript effect
Style style = cell.getStyle();
Font font = style.getFont();
font.setSubscript(true);
cell.setStyle(style);

Ayar Üst Simgesi

ile metne üst simge uygulaYazı tipi nesneninsetSuperscriptEmlak.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// The path to the documents directory.
String dataDir = Utils.getSharedDataDir(SetSubscript.class) + "data/";
// Instantiating a Workbook object
Workbook workbook = new Workbook();
// Accessing the added worksheet in the Excel file
int sheetIndex = workbook.getWorksheets().add();
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex);
Cells cells = worksheet.getCells();
// Adding some value to the "A1" cell
Cell cell = cells.get("A1");
cell.setValue("Hello Aspose!");
// Setting superscript effect
Style style = cell.getStyle();
Font font = style.getFont();
font.setSuperscript(true);
cell.setStyle(style);

ileri konular