diff --git a/Getting Started/Mac/Convert Excel to Image/ConvertExcelToImage.sln b/Getting Started/Mac/Convert Excel to Image/ConvertExcelToImage.sln new file mode 100644 index 00000000..826c2dc4 --- /dev/null +++ b/Getting Started/Mac/Convert Excel to Image/ConvertExcelToImage.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36127.28 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConvertExcelToImage", "ConvertExcelToImage\ConvertExcelToImage.csproj", "{9321C142-CC8C-4A7D-BFE5-3259FF495046}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9321C142-CC8C-4A7D-BFE5-3259FF495046}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9321C142-CC8C-4A7D-BFE5-3259FF495046}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9321C142-CC8C-4A7D-BFE5-3259FF495046}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9321C142-CC8C-4A7D-BFE5-3259FF495046}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1CC01B54-5001-4231-9D68-1202BB28E3E4} + EndGlobalSection +EndGlobal diff --git a/Getting Started/Mac/Convert Excel to Image/ConvertExcelToImage/ConvertExcelToImage.csproj b/Getting Started/Mac/Convert Excel to Image/ConvertExcelToImage/ConvertExcelToImage.csproj new file mode 100644 index 00000000..2e326376 --- /dev/null +++ b/Getting Started/Mac/Convert Excel to Image/ConvertExcelToImage/ConvertExcelToImage.csproj @@ -0,0 +1,20 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + + + Always + + + + diff --git a/Getting Started/Mac/Convert Excel to Image/ConvertExcelToImage/Data/Sample.xlsx b/Getting Started/Mac/Convert Excel to Image/ConvertExcelToImage/Data/Sample.xlsx new file mode 100644 index 00000000..a7c5e8d7 Binary files /dev/null and b/Getting Started/Mac/Convert Excel to Image/ConvertExcelToImage/Data/Sample.xlsx differ diff --git a/Getting Started/Mac/Convert Excel to Image/ConvertExcelToImage/Output/.gitkeep b/Getting Started/Mac/Convert Excel to Image/ConvertExcelToImage/Output/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Getting Started/Mac/Convert Excel to Image/ConvertExcelToImage/Program.cs b/Getting Started/Mac/Convert Excel to Image/ConvertExcelToImage/Program.cs new file mode 100644 index 00000000..b8e1ec8f --- /dev/null +++ b/Getting Started/Mac/Convert Excel to Image/ConvertExcelToImage/Program.cs @@ -0,0 +1,39 @@ +using Syncfusion.XlsIO; +using Syncfusion.XlsIORenderer; + +namespace ConvertExcelToImage +{ + class Program + { + public static void Main(string[] args) + { + using (ExcelEngine excelEngine = new ExcelEngine()) + { + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + FileStream excelStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read); + IWorkbook workbook = application.Workbooks.Open(excelStream); + IWorksheet worksheet = workbook.Worksheets[0]; + + //Initialize XlsIORenderer + application.XlsIORenderer = new XlsIORenderer(); + + //Create the MemoryStream to save the image + MemoryStream imageStream = new MemoryStream(); + + //Save the converted image to MemoryStream + worksheet.ConvertToImage(worksheet.UsedRange, imageStream); + imageStream.Position = 0; + + #region Save + FileStream outputStream = new FileStream(Path.GetFullPath("Output/Sample.jpeg"), FileMode.Create, FileAccess.Write); + imageStream.CopyTo(outputStream); + #endregion + + //Dispose streams + outputStream.Dispose(); + excelStream.Dispose(); + } + } + } +} \ No newline at end of file