static void Main(string[] args) { // If using Professional version, put your serial key below. SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY"); ExcelFile ef = new ExcelFile(); ExcelWorksheet ws = ef.Worksheets.Add("Inline Text Formatting"); ws.Cells[0, 0].Value = "Inline text formatting examples:"; ws.PrintOptions.PrintGridlines = true; // Column width of 20 characters. ws.Columns[0].Width = 20 * 256; ws.Cells[2, 0].Value = "This is big and red text!"; // Apply size to 'big and red' part of text ws.Cells[2, 0].GetCharacters(8, 11).Font.Size = 400; // Apply color to 'red' part of text ws.Cells[2, 0].GetCharacters(16, 3).Font.Color = SpreadsheetColor.FromName(ColorName.Red); // Format cell content ws.Cells[4, 0].Value = "Formatting selected characters with GemBox.Spreadsheet component."; ws.Cells[4, 0].Style.Font.Color = SpreadsheetColor.FromName(ColorName.Blue); ws.Cells[4, 0].Style.Font.Italic = true; ws.Cells[4, 0].Style.WrapText = true; // Get characters from index 36 to the end of string FormattedCharacterRange characters = ws.Cells[4, 0].GetCharacters(36); // Apply color and underline to selected characters characters.Font.Color = SpreadsheetColor.FromName(ColorName.Orange); characters.Font.UnderlineStyle = UnderlineStyle.Single; // Write selected characters ws.Cells[6, 0].Value = "Selected characters: " + characters.Text; ef.Save("Inline Text Formatting.xlsx"); }
static void Main(string[] args) { // If using Professional version, put your serial key below. SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY"); ExcelFile ef = new ExcelFile(); ExcelWorksheet ws = ef.Worksheets.Add("Comments"); ws.Cells[0, 0].Value = "Comment examples:"; ws.Cells[2, 1].Comment.Text = "Empty cell."; ws.Cells[4, 1].Value = 5; ws.Cells[4, 1].Comment.Text = "Cell with a number."; ws.Cells["B7"].Value = "Cell B7"; ExcelComment comment = ws.Cells["B7"].Comment; comment.Text = "Some formatted text.\nComment is:\na) multiline,\nb) large,\nc) visible, and \nd) formatted."; comment.IsVisible = true; comment.TopLeftCell = new AnchorCell(ws.Columns[3], ws.Rows[4], true); comment.BottomRightCell = new AnchorCell(ws.Columns[5], ws.Rows[10], false); // Get first 20 characters of a string FormattedCharacterRange characters = comment.GetCharacters(0, 20); // Apply color, italic and size to selected characters characters.Font.Color = SpreadsheetColor.FromName(ColorName.Orange); characters.Font.Italic = true; characters.Font.Size = 300; // Apply color to 'formatted' part of text comment.GetCharacters(5, 9).Font.Color = SpreadsheetColor.FromName(ColorName.Red); ef.Save("Comments.xlsx"); }