Skip to content

Commit b85a45d

Browse files
authored
Merge pull request #216 from SyncfusionExamples/966587-ExcelToImageMac
966587-Add UG for converting Excel document to Image in Mac
2 parents f4b9770 + d2c8e4e commit b85a45d

File tree

5 files changed

+84
-0
lines changed

5 files changed

+84
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.14.36127.28 d17.14
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConvertExcelToImage", "ConvertExcelToImage\ConvertExcelToImage.csproj", "{9321C142-CC8C-4A7D-BFE5-3259FF495046}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{9321C142-CC8C-4A7D-BFE5-3259FF495046}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{9321C142-CC8C-4A7D-BFE5-3259FF495046}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{9321C142-CC8C-4A7D-BFE5-3259FF495046}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{9321C142-CC8C-4A7D-BFE5-3259FF495046}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {1CC01B54-5001-4231-9D68-1202BB28E3E4}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Syncfusion.XlsIORenderer.Net.Core" Version="*" />
12+
</ItemGroup>
13+
14+
<ItemGroup>
15+
<None Update="Output\*">
16+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
17+
</None>
18+
</ItemGroup>
19+
20+
</Project>
Binary file not shown.

Getting Started/Mac/Convert Excel to Image/ConvertExcelToImage/Output/.gitkeep

Whitespace-only changes.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using Syncfusion.XlsIO;
2+
using Syncfusion.XlsIORenderer;
3+
4+
namespace ConvertExcelToImage
5+
{
6+
class Program
7+
{
8+
public static void Main(string[] args)
9+
{
10+
using (ExcelEngine excelEngine = new ExcelEngine())
11+
{
12+
IApplication application = excelEngine.Excel;
13+
application.DefaultVersion = ExcelVersion.Xlsx;
14+
FileStream excelStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read);
15+
IWorkbook workbook = application.Workbooks.Open(excelStream);
16+
IWorksheet worksheet = workbook.Worksheets[0];
17+
18+
//Initialize XlsIORenderer
19+
application.XlsIORenderer = new XlsIORenderer();
20+
21+
//Create the MemoryStream to save the image
22+
MemoryStream imageStream = new MemoryStream();
23+
24+
//Save the converted image to MemoryStream
25+
worksheet.ConvertToImage(worksheet.UsedRange, imageStream);
26+
imageStream.Position = 0;
27+
28+
#region Save
29+
FileStream outputStream = new FileStream(Path.GetFullPath("Output/Sample.jpeg"), FileMode.Create, FileAccess.Write);
30+
imageStream.CopyTo(outputStream);
31+
#endregion
32+
33+
//Dispose streams
34+
outputStream.Dispose();
35+
excelStream.Dispose();
36+
}
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)