Skip to content

Commit 83fd950

Browse files
264527-NamedRange
1 parent fbb2cb0 commit 83fd950

File tree

4 files changed

+79
-0
lines changed

4 files changed

+79
-0
lines changed
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.36127.28 d17.14
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Discontinuous Named Ranges", "Discontinuous Named Ranges\Discontinuous Named Ranges.csproj", "{82F1D1C3-EB0A-4C8C-92FA-7B25000B27B8}"
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+
{82F1D1C3-EB0A-4C8C-92FA-7B25000B27B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{82F1D1C3-EB0A-4C8C-92FA-7B25000B27B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{82F1D1C3-EB0A-4C8C-92FA-7B25000B27B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{82F1D1C3-EB0A-4C8C-92FA-7B25000B27B8}.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 = {DB34F7F9-90F8-41CC-AEE8-1E232DB32423}
24+
EndGlobalSection
25+
EndGlobal
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>net8.0</TargetFramework>
6+
<RootNamespace>Discontinuous_Named_Ranges</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.XlsIO.Net.Core" Version="*" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<None Update="Output\*">
17+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
18+
</None>
19+
</ItemGroup>
20+
</Project>

Use Cases/Create named ranges for discontinuous cell ranges/.NET/Discontinuous Named Ranges/Discontinuous Named Ranges/Output/.gitkeep

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
IWorkbook workbook = application.Workbooks.Create(1);
12+
IWorksheet sheet = workbook.Worksheets[0];
13+
14+
//Create a range collection for discontinuous cells
15+
IRanges ranges = sheet.CreateRangesCollection();
16+
17+
//Add different ranges to the collection
18+
ranges.Add(sheet["D2:D3"]);
19+
ranges.Add(sheet["D10:D11"]);
20+
21+
//Create a named range with the collection
22+
workbook.Names.Add("test", ranges);
23+
24+
#region Save
25+
//Saving the workbook
26+
FileStream outputStream = new FileStream(Path.GetFullPath("Output.xlsx"), FileMode.Create, FileAccess.Write);
27+
workbook.SaveAs(outputStream);
28+
#endregion
29+
30+
//Dispose streams
31+
outputStream.Dispose();
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)