Skip to content

897576 - Add samples for how to get/set row height and column width in pixels #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
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="*" />
</ItemGroup>

</Project>
Loading