Ändra teckensnitt och färg i en cell
Contents
[
Hide
]
I det här avsnittet kommer vi att diskutera hur man ändrar teckensnittet och teckensnittsfärgen för en cell i GridDesktop. Den här funktionen ger utvecklarna mer djupgående kontroll över arbetsblad. Med den här funktionen kan utvecklare anpassa teckensnittet och färgen för valfri cell.
Ändra teckensnitt och färg i en cell
För att ändra teckensnittet och färgen i en cell med hjälp av Aspose.Cells.GridDesktop, följ stegen nedan:
- Kom åt något önskat Kalkylblad
- Öppna en Cell vars teckensnitt och färg ska ändras
- Skapa en anpassad Font
- Ställ in Teckensnittet för Cellen till det anpassade
- Slutligen, ställ in Teckensnittsfärgen för Cellen till valfri Färg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Accessing the worksheet of the Grid that is currently active | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Accessing a cell using its name | |
GridCell cell = sheet.Cells["A1"]; | |
// Creating a customized Font object | |
Font font = new Font("Arial", 10, FontStyle.Bold); | |
// Setting the font of the cell to the customized Font object | |
cell.SetFont(font); | |
// Setting the font color of the cell to Blue | |
cell.SetFontColor(Color.Blue); |
Om du bara behöver information om teckensnittet eller teckensnittsfärgen i cellen kan du också använda metoderna GetFont och GetFontColor för cellen.