-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #143 from SyncfusionExamples/261741-Comments-XlsIO
261741 - Add sample for formatting comment
- Loading branch information
Showing
5 changed files
with
100 additions
and
3 deletions.
There are no files selected for viewing
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
25 changes: 25 additions & 0 deletions
25
Excel Shapes/Format Comment/.NET/Formatting Comment/Formatting Comment.sln
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
20 changes: 20 additions & 0 deletions
20
...hapes/Format Comment/.NET/Formatting Comment/Formatting Comment/Formatting Comment.csproj
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<RootNamespace>Formatting_Comment</RootNamespace> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Syncfusion.XlsIO.Net.Core" Version="*" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="Output\*"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
</Project> |
Empty file.
49 changes: 49 additions & 0 deletions
49
Excel Shapes/Format Comment/.NET/Formatting Comment/Formatting Comment/Program.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} | ||
} | ||
} |