Skip to content

Commit

Permalink
Format rows and columns
Browse files Browse the repository at this point in the history
  • Loading branch information
Kurmitha4004 committed Jul 26, 2024
1 parent 3f8b9a3 commit edf28ce
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 0 deletions.
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}") = "Get Row Height and Column Width in Pixels", "Get Row Height and Column Width in Pixels\Get Row Height and Column Width in Pixels.csproj", "{2E122617-D2C7-4102-AF81-CEDA4F7F77BC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2E122617-D2C7-4102-AF81-CEDA4F7F77BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E122617-D2C7-4102-AF81-CEDA4F7F77BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E122617-D2C7-4102-AF81-CEDA4F7F77BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E122617-D2C7-4102-AF81-CEDA4F7F77BC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6121E09A-8AC5-4FBC-99AB-85C44D57F5A6}
EndGlobalSection
EndGlobal
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Get_Row_Height_and_Column_Width_in_Pixels</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.XlsIO.Net.Core" Version="*" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Syncfusion.XlsIO;
namespace Get_Row_Height_and_Column_Width_in_Pixels
{
class Program
{
public static void Main(string[] args)
{
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;

//Load an existing file
FileStream inputStream = new FileStream("../../../Data/InputTemplate.xlsx", FileMode.Open);
IWorkbook workbook = application.Workbooks.Open(inputStream);
IWorksheet worksheet = workbook.Worksheets[0];

//Get row height in pixels
int rowheight = worksheet.GetRowHeightInPixels(1);

//Get column width in pixels
int columnwidth = worksheet.GetColumnWidthInPixels(1);

Console.WriteLine($"Row Height: {rowheight}");
Console.WriteLine($"Column Width: {columnwidth}");

//Dispose stream
inputStream.Dispose();
}
}
}
}
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}") = "Set Row Height and Column Width in Pixels", "Set Row Height and Column Width in Pixels\Set Row Height and Column Width in Pixels.csproj", "{6B56B9B2-0F14-4C38-9ACE-AB023040D00A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6B56B9B2-0F14-4C38-9ACE-AB023040D00A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6B56B9B2-0F14-4C38-9ACE-AB023040D00A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6B56B9B2-0F14-4C38-9ACE-AB023040D00A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6B56B9B2-0F14-4C38-9ACE-AB023040D00A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5CC7961F-D80D-4D04-8877-C28AF652E914}
EndGlobalSection
EndGlobal
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Syncfusion.XlsIO;
namespace Set_Row_Height_and_Column_width_in_pixels
{
class Program
{
public static void Main(string[] args)
{
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;

//Load an existing file
FileStream inputStream = new FileStream("../../../Data/InputTemplate.xlsx", FileMode.Open);
IWorkbook workbook = application.Workbooks.Open(inputStream);
IWorksheet worksheet = workbook.Worksheets[0];

//Set row height in pixels
worksheet.SetRowHeightInPixels(2, 50);

//Get column width in pixels
worksheet.SetColumnWidthInPixels(3, 100);

//Save the workbook as stream
FileStream outputStream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.Write);
workbook.SaveAs(outputStream);

//Dispose stream
inputStream.Dispose();
outputStream.Dispose();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Set_Row_Height_and_Column_Width_in_Pixels</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.XlsIO.Net.Core" Version="26.2.5" />
</ItemGroup>

</Project>

0 comments on commit edf28ce

Please sign in to comment.