Skip to content

Commit e412ac9

Browse files
966385-ExcelToImageLinuxExample
1 parent 4bf6ee3 commit e412ac9

File tree

5 files changed

+87
-0
lines changed

5 files changed

+87
-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", "{2E126C02-CB69-4F60-8799-4B80C8C26DCE}"
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+
{2E126C02-CB69-4F60-8799-4B80C8C26DCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{2E126C02-CB69-4F60-8799-4B80C8C26DCE}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{2E126C02-CB69-4F60-8799-4B80C8C26DCE}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{2E126C02-CB69-4F60-8799-4B80C8C26DCE}.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 = {690FF22D-9A18-450A-B83E-92183DFE585C}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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="HarfBuzzSharp.NativeAssets.Linux" Version="*" />
12+
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="*" />
13+
<PackageReference Include="Syncfusion.XlsIORenderer.Net.Core" Version="*" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<None Update="Output\*">
18+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
19+
</None>
20+
</ItemGroup>
21+
22+
</Project>
Binary file not shown.

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

Whitespace-only changes.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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 XlsIO renderer.
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+
//Saving the workbook
30+
FileStream outputStream = new FileStream(Path.GetFullPath("Output/Sample.jpeg"), FileMode.Create, FileAccess.Write);
31+
imageStream.CopyTo(outputStream);
32+
#endregion
33+
34+
//Dispose streams
35+
outputStream.Dispose();
36+
excelStream.Dispose();
37+
}
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)