diff --git a/Excel Shapes/Comment/.NET/Comment/Comment/Program.cs b/Excel Shapes/Comment/.NET/Comment/Comment/Program.cs index 85398111..2b80e6fd 100644 --- a/Excel Shapes/Comment/.NET/Comment/Comment/Program.cs +++ b/Excel Shapes/Comment/.NET/Comment/Comment/Program.cs @@ -12,13 +12,16 @@ static void Main(string[] args) IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; IWorkbook workbook = application.Workbooks.Create(1); - IWorksheet sheet = workbook.Worksheets[0]; + IWorksheet worksheet = workbook.Worksheets[0]; //Adding comments to a cell - sheet.Range["A1"].AddComment().Text = "Comments"; + worksheet.Range["A1"].AddComment().Text = "Comments"; + + //Adding comments with author to a cell + worksheet.Range["A3"].AddComment().Text = worksheet.Range["A3"].Comment.Author; //Add Rich Text Comments - IRange range = sheet.Range["A6"]; + IRange range = worksheet.Range["A6"]; range.AddComment().RichText.Text = "RichText"; IRichTextString richText = range.Comment.RichText; diff --git a/Excel Shapes/Format Comment/.NET/Formatting Comment/Formatting Comment.sln b/Excel Shapes/Format Comment/.NET/Formatting Comment/Formatting Comment.sln new file mode 100644 index 00000000..64de44cd --- /dev/null +++ b/Excel Shapes/Format Comment/.NET/Formatting Comment/Formatting Comment.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34310.174 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Formatting Comment", "Formatting Comment\Formatting Comment.csproj", "{7BEC1F35-BC70-459B-9751-6F8E9E1A8311}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7BEC1F35-BC70-459B-9751-6F8E9E1A8311}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7BEC1F35-BC70-459B-9751-6F8E9E1A8311}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7BEC1F35-BC70-459B-9751-6F8E9E1A8311}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7BEC1F35-BC70-459B-9751-6F8E9E1A8311}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {87B43642-0128-46FA-96BE-B5F21C14DAC9} + EndGlobalSection +EndGlobal diff --git a/Excel Shapes/Format Comment/.NET/Formatting Comment/Formatting Comment/Formatting Comment.csproj b/Excel Shapes/Format Comment/.NET/Formatting Comment/Formatting Comment/Formatting Comment.csproj new file mode 100644 index 00000000..ec386256 --- /dev/null +++ b/Excel Shapes/Format Comment/.NET/Formatting Comment/Formatting Comment/Formatting Comment.csproj @@ -0,0 +1,20 @@ + + + + Exe + net8.0 + Formatting_Comment + enable + enable + + + + + + + + + Always + + + diff --git a/Excel Shapes/Format Comment/.NET/Formatting Comment/Formatting Comment/Output/.gitkeep b/Excel Shapes/Format Comment/.NET/Formatting Comment/Formatting Comment/Output/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Excel Shapes/Format Comment/.NET/Formatting Comment/Formatting Comment/Program.cs b/Excel Shapes/Format Comment/.NET/Formatting Comment/Formatting Comment/Program.cs new file mode 100644 index 00000000..4d50e400 --- /dev/null +++ b/Excel Shapes/Format Comment/.NET/Formatting Comment/Formatting Comment/Program.cs @@ -0,0 +1,49 @@ +using Syncfusion.XlsIO; + +namespace Formatting_Comment +{ + class Program + { + public static void Main(string[] args) + { + using (ExcelEngine excelEngine = new ExcelEngine()) + { + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Create(1); + IWorksheet worksheet = workbook.Worksheets[0]; + + //Adding comment in the worksheet with text + worksheet.Range["A1"].AddComment(); + ICommentShape comment = worksheet.Comments[0]; + comment.Text = "Comment"; + + //Set size for the comment + comment.Height = 150; + comment.Width = 100; + + //Set position for the comment + comment.Left = 200; + comment.Top = 100; + + //Set alignment for the comment + comment.HAlignment = ExcelCommentHAlign.Right; + comment.VAlignment = ExcelCommentVAlign.Bottom; + + //Set fill for the comment + comment.Fill.TwoColorGradient(); + comment.Fill.GradientStyle = ExcelGradientStyle.Horizontal; + comment.Fill.GradientColorType = ExcelGradientColor.TwoColor; + comment.Fill.ForeColorIndex = ExcelKnownColors.Red; + comment.Fill.BackColorIndex = ExcelKnownColors.White; + + //Saving the workbook as stream + FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.ReadWrite); + workbook.SaveAs(outputStream); + + //Dispose stream + outputStream.Dispose(); + } + } + } +} \ No newline at end of file