Skip to content

Commit f296d1c

Browse files
968947-KBStudentGrade
1 parent ac6737c commit f296d1c

File tree

5 files changed

+83
-0
lines changed

5 files changed

+83
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.14.36221.1 d17.14
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StudentRank", "StudentRank\StudentRank.csproj", "{74DF17A2-0297-4BA1-A7BE-C8E5FF2186E2}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{74DF17A2-0297-4BA1-A7BE-C8E5FF2186E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{74DF17A2-0297-4BA1-A7BE-C8E5FF2186E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{74DF17A2-0297-4BA1-A7BE-C8E5FF2186E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{74DF17A2-0297-4BA1-A7BE-C8E5FF2186E2}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {729FF827-E15D-4257-A56F-BC88645126FA}
24+
EndGlobalSection
25+
EndGlobal
Binary file not shown.

Use Cases/Student Rank/.NET/StudentRank/StudentRank/Output/.gitkeep

Whitespace-only changes.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using Syncfusion.XlsIO;
2+
3+
class Program
4+
{
5+
public static void Main(string[] args)
6+
{
7+
using (ExcelEngine excelEngine = new ExcelEngine())
8+
{
9+
IApplication application = excelEngine.Excel;
10+
application.DefaultVersion = ExcelVersion.Xlsx;
11+
FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/Input.xlsx"), FileMode.Open, FileAccess.Read);
12+
IWorkbook workbook = application.Workbooks.Open(inputStream);
13+
IWorksheet worksheet = workbook.Worksheets[0];
14+
15+
worksheet["E1"].Text = "Rank";
16+
worksheet["E1"].CellStyle.Font.Bold = true;
17+
18+
//Apply grading logic using nested IF formulas
19+
worksheet["E2"].Formula = "=IF(D2>=270,\"A\", IF(D2>=250,\"B\", IF(D2>=230,\"C\",\"D\")))";
20+
worksheet["E3"].Formula = "=IF(D3>=270,\"A\", IF(D3>=250,\"B\", IF(D3>=230,\"C\",\"D\")))";
21+
worksheet["E4"].Formula = "=IF(D4>=270,\"A\", IF(D4>=250,\"B\", IF(D4>=230,\"C\",\"D\")))";
22+
worksheet["E5"].Formula = "=IF(D5>=270,\"A\", IF(D5>=250,\"B\", IF(D5>=230,\"C\",\"D\")))";
23+
worksheet["E6"].Formula = "=IF(D6>=270,\"A\", IF(D6>=250,\"B\", IF(D6>=230,\"C\",\"D\")))";
24+
worksheet["E7"].Formula = "=IF(D7>=270,\"A\", IF(D7>=250,\"B\", IF(D7>=230,\"C\",\"D\")))";
25+
26+
//Align given range to the right
27+
worksheet.Range["E2:E7"].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignRight;
28+
29+
//Saving the workbook
30+
FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.ReadWrite);
31+
workbook.SaveAs(outputStream);
32+
33+
//Dispose streams
34+
outputStream.Dispose();
35+
inputStream.Dispose();
36+
}
37+
}
38+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Syncfusion.XlsIO.Net.Core" Version="*" />
12+
</ItemGroup>
13+
14+
<ItemGroup>
15+
<None Update="Output\*">
16+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
17+
</None>
18+
</ItemGroup>
19+
20+
</Project>

0 commit comments

Comments
 (0)