Skip to content

Commit 1693093

Browse files
991263-FirstUsedCellSample
1 parent d4d03cc commit 1693093

File tree

5 files changed

+59
-0
lines changed

5 files changed

+59
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Solution>
2+
<Project Path="FirstUsedCellInUsedRange/FirstUsedCellInUsedRange.csproj" />
3+
</Solution>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net10.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+
<None Update="Data\*">
19+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
20+
</None>
21+
</ItemGroup>
22+
23+
</Project>

FAQ/First used cell in used range/.NET/FirstUsedCellInUsedRange/FirstUsedCellInUsedRange/Output/.gitkeep

Whitespace-only changes.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using Syncfusion.XlsIO;
2+
3+
namespace FirstUsedCellInUsedRange
4+
{
5+
class Program
6+
{
7+
public static void Main(string[] args)
8+
{
9+
using (ExcelEngine excelEngine = new ExcelEngine())
10+
{
11+
IApplication application = excelEngine.Excel;
12+
application.DefaultVersion = ExcelVersion.Xlsx;
13+
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/Input.xlsx"));
14+
IWorksheet worksheet = workbook.Worksheets[0];
15+
16+
//Get the used range of the worksheet
17+
IRange usedRange = worksheet.UsedRange;
18+
19+
//Get the first cell from the used range
20+
IRange firstCell = worksheet.Range[usedRange.Row, usedRange.Column];
21+
22+
//Get the address of the first cell
23+
string firstCellAddress = firstCell.AddressLocal;
24+
25+
//Display the address of the first cell
26+
Console.WriteLine("The address of the first used cell in used range is: " + firstCellAddress);
27+
28+
//Saving the workbook
29+
workbook.SaveAs(Path.GetFullPath(@"Output/Output.xlsx"));
30+
}
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)