static void Main(string[] args) { var workbook = new Workbook(); var worksheet = workbook.Worksheets[0]; worksheet.GetRange("A1:A10").SetRowsHeight(60); worksheet.Columns["A"].WidthPixels = 100; worksheet.Columns["B"].WidthPixels = 100; worksheet["A2"].AddComment("DR-IT", "Comment"); FormatComment(worksheet, "A2"); worksheet["A2"].Comment.Line.Color = Color.Lime; worksheet["A3"].AddComment("DR-IT", "Comment"); FormatComment(worksheet, "A3"); worksheet["A3"].Comment.Line.Color = Color.Red; worksheet["A3"].Comment.Line.Transparency = 0.5m; worksheet["A4"].AddComment("DR-IT", "Comment"); FormatComment(worksheet, "A4"); worksheet["A4"].Comment.Line.WidthPoints = 5; worksheet["A5"].AddComment("DR-IT", "Comment"); FormatComment(worksheet, "A5"); worksheet["A5"].Comment.Fill.Color = Color.Yellow; worksheet["A6"].AddComment("DR-IT", "Comment"); FormatComment(worksheet, "A6"); worksheet["A6"].Comment.Fill.Color = Color.Red; worksheet["A6"].Comment.Fill.Type = CommentFillEffect.Gradient; worksheet["A6"].Comment.Fill.Gradient.DarkenPercentage = 0.6m; var richText = new RichTextParagraph(); richText.Runs.Add(new RichTextRun() { FontName = "Arial", FontSize = 10, Foreground = SpreadsheetColor.Red, Text = "Arial 10 Red" }); richText.Runs.Add(new RichTextRun() { FontName = "Cambria", FontSize = 6, Foreground = SpreadsheetColor.Green, Text = "Cambria 6 Green" }); worksheet["A7"].AddComment("DR-IT", richText); FormatComment(worksheet, "A7"); workbook.SaveAs(@"..\Out\Comments.xlsx"); }
public static void Fonts(Workbook workbook) { var worksheet = workbook.Worksheets[0]; worksheet.Name = "Fonts"; worksheet.Columns[0].WidthCharacters = 11; worksheet.Columns[1].WidthCharacters = 25; worksheet["A1"].Value = "Font Name:"; worksheet["B1"].Value = "12 points"; worksheet["B1"].Font.Size = 12; worksheet["A2"].Value = "Font Name:"; worksheet["B2"].Value = "Arial"; worksheet["B2"].Font.Name = "Arial"; worksheet["B3"].Value = "Bold"; worksheet["B3"].Font.Bold = true; worksheet["B4"].Value = "Italic"; worksheet["B4"].Font.Italic = true; worksheet["B5"].Value = "Strikethrough"; worksheet["B5"].Font.Strikethrough = true; worksheet["B6"].Value = "Subscript"; worksheet["B6"].Font.Subscript = true; worksheet["B7"].Value = "Superscript"; worksheet["B7"].Font.Superscript = true; worksheet["B8"].Value = "UnderLine Single"; worksheet["B8"].Font.Underline = SpreadsheetUnderline.Single; worksheet["B9"].Value = "UnderLine Double Accounting"; worksheet["B9"].Font.Underline = SpreadsheetUnderline.DoubleAccounting; worksheet["A10"].Value = "Font Color:"; worksheet["B10"].Value = "Red"; worksheet["B10"].Font.Color = SpreadsheetColor.Red; var paragraph = new RichTextParagraph(); paragraph.Runs.Add(new RichTextRun("12 points ") { FontSize = 12 }); paragraph.Runs.Add(new RichTextRun("Arial ") { FontName = "Arial" }); paragraph.Runs.Add(new RichTextRun("bold ") { Bold = true }); paragraph.Runs.Add(new RichTextRun("red") { Foreground = SpreadsheetColor.Red }); worksheet["B11"].RichText = paragraph; }