-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #108 from SyncfusionExamples/893873-Pictures
Add the sample for move and size pictures with cells
- Loading branch information
Showing
4 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
...ve and Size with cells/NET Standard/Move and Size with cells/Move and Size with cells.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Binary file added
BIN
+40.9 KB
...s/NET Standard/Move and Size with cells/Move and Size with cells/Data/Image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions
15
...tandard/Move and Size with cells/Move and Size with cells/Move and Size with cells.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
48 changes: 48 additions & 0 deletions
48
...Size with cells/NET Standard/Move and Size with cells/Move and Size with cells/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} | ||
} |