Skip to content

Commit

Permalink
Merge pull request #108 from SyncfusionExamples/893873-Pictures
Browse files Browse the repository at this point in the history
Add the sample for move and size pictures with cells
  • Loading branch information
Mohan2401 authored Jul 3, 2024
2 parents 79a7083 + ce4cc95 commit f04884d
Show file tree
Hide file tree
Showing 4 changed files with 88 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}") = "Move and Size with cells", "Move and Size with cells\Move and Size with cells.csproj", "{6396970E-0389-4417-A263-9B5B595C2B17}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6396970E-0389-4417-A263-9B5B595C2B17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6396970E-0389-4417-A263-9B5B595C2B17}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6396970E-0389-4417-A263-9B5B595C2B17}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6396970E-0389-4417-A263-9B5B595C2B17}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {473270A2-049A-46EC-A408-FADB02AEFA2C}
EndGlobalSection
EndGlobal
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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>Move_and_Size_with_cells</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

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

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using Syncfusion.XlsIO;
using Syncfusion.XlsIO.Implementation;

namespace Move_and_Size_with_cells
{
class Program
{
public static void Main(string[] args)
{
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];

//Adding a picture
FileStream imageStream = new FileStream("../../../Data/Image.png", FileMode.Open, FileAccess.Read);
IPictureShape shape = worksheet.Pictures.AddPicture(1, 1, 5, 3, imageStream);
shape = worksheet.Pictures.AddPicture(1, 5, 5, 7, imageStream);

//Set move picture with cell
shape.IsMoveWithCell = true;

//Set size picture with cell
shape.IsSizeWithCell = true;

//Hide the column
worksheet.HideColumn(5);

//Saving the workbook as stream
FileStream OutputStream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite);
workbook.SaveAs(OutputStream);

//Dispose streams
imageStream.Dispose();
OutputStream.Dispose();

System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo = new System.Diagnostics.ProcessStartInfo("Output.xlsx")
{
UseShellExecute = true
};
process.Start();
}
}
}
}

0 comments on commit f04884d

Please sign in to comment.