diff --git a/Document-Processing/Excel/Conversions/CSV-to-Excel/NET/CSV-to-Excel-Conversion.md b/Document-Processing/Excel/Conversions/CSV-to-Excel/NET/CSV-to-Excel-Conversion.md index 4aaeb2acc9..0496cc16cc 100644 --- a/Document-Processing/Excel/Conversions/CSV-to-Excel/NET/CSV-to-Excel-Conversion.md +++ b/Document-Processing/Excel/Conversions/CSV-to-Excel/NET/CSV-to-Excel-Conversion.md @@ -1,6 +1,6 @@ --- title: Syncfusion CSV to Excel Conversion -description: In this section, you can learn how to convert CSV docuemnt to Excel document using Syncfusion Essential XlsIO. +description: Lists how to convert a CSV (or TSV) document to an Excel workbook using the Syncfusion .NET Excel (XlsIO) library. platform: document-processing control: XlsIO documentation: UG @@ -8,16 +8,18 @@ documentation: UG # CSV to Excel Conversion -XlsIO supports converting CSV data to Excel files by saving the workbook using the [SaveAs](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IWorkbook.html#Syncfusion_XlsIO_IWorkbook_SaveAs_System_IO_Stream_) method. When opening a CSV file, users can specify various delimiters to structure the data appropriately. +XlsIO can read a CSV file with [`IWorkbooks.Open`](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IWorkbooks.html#Syncfusion_XlsIO_IWorkbooks_Open_System_String_System_String_) and write the result to an Excel workbook with [`IWorkbook.SaveAs`](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IWorkbook.html#Syncfusion_XlsIO_IWorkbook_SaveAs_System_String_). The default delimiter when opening a CSV is a comma (`,`). To read other delimited formats, pass the matching character to the `Open` overload. -**Delimiters Used in CSV files** +N> IMPORTANT: Before running the samples on this page, install the required NuGet package for your target platform and register your Syncfusion license key. For more information, see the [Licensing overview](https://help.syncfusion.com/document-processing/licensing/overview). -* Comma (,) -* Tab (\t) -* Semicolon (;) -* Colon (:) -* Space ( ) -* Equals Sign (=) +The supported delimiters are: + +* **Comma** (`,`) — the default. +* **Tab** (`\t`) — used to open a TSV file. +* **Semicolon** (`;`) +* **Colon** (`:`) +* **Space** (` `) +* **Equals** (`=`) — used by some locales that export with leading `=` on every value; not a true separator. Use a different delimiter (for example `,` or `;`) and add a quote/unescape step in your own code. The following code example illustrates how to convert a CSV to an Excel file. @@ -52,7 +54,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -Using excelEngine As ExcelEngine = New ExcelEngine() +Using excelEngine As New ExcelEngine() Dim application As IApplication = excelEngine.Excel application.DefaultVersion = ExcelVersion.Xlsx @@ -63,12 +65,14 @@ Using excelEngine As ExcelEngine = New ExcelEngine() workbook.SaveAs("Output.xlsx") End Using {% endhighlight %} -{% endtabs %} +{% endtabs %} A complete working example to convert CSV to an Excel file in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/CSV%20to%20Excel/CSV%20to%20Excel/.NET/CSV%20to%20Excel). ## TSV to Excel Conversion +**TSV (Tab-Separated Values)** files are loaded by passing the tab character (`\t` in C#, `vbTab` in VB.NET) as the delimiter to `Workbooks.Open`. The workbook is then written to `.xlsx` with `SaveAs`. + The following code example illustrates how to convert a TSV to an Excel file. {% tabs %} @@ -108,10 +112,18 @@ Using excelEngine As New ExcelEngine() ' Open the TSV file Dim workbook As IWorkbook = application.Workbooks.Open("InputTemplate.tsv", vbTab) - ' Save in workbook + ' Saving the workbook workbook.SaveAs("Output.xlsx") End Using {% endhighlight %} -{% endtabs %} +{% endtabs %} -A complete working example to convert TSV to an Excel file in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/TSV%20to%20Excel/TSV%20to%20Excel/.NET/TSV%20to%20Excel). \ No newline at end of file +A complete working example to convert TSV to an Excel file in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/TSV%20to%20Excel/TSV%20to%20Excel/.NET/TSV%20to%20Excel). + +## See also + +* [Convert Excel to CSV (or TSV)](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-csv/overview) +* [Convert Excel to PDF](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-pdf/overview) +* [Convert Excel to image](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-image/overview) +* [NuGet packages for Excel (XlsIO)](https://help.syncfusion.com/document-processing/excel/getting-started/nuget-packages-required) +* [Syncfusion .NET Excel (XlsIO) — Licensing overview](https://help.syncfusion.com/document-processing/licensing/overview) \ No newline at end of file diff --git a/Document-Processing/Excel/Conversions/CSV-to-Excel/overview.md b/Document-Processing/Excel/Conversions/CSV-to-Excel/overview.md index 4aaeb2acc9..0496cc16cc 100644 --- a/Document-Processing/Excel/Conversions/CSV-to-Excel/overview.md +++ b/Document-Processing/Excel/Conversions/CSV-to-Excel/overview.md @@ -1,6 +1,6 @@ --- title: Syncfusion CSV to Excel Conversion -description: In this section, you can learn how to convert CSV docuemnt to Excel document using Syncfusion Essential XlsIO. +description: Lists how to convert a CSV (or TSV) document to an Excel workbook using the Syncfusion .NET Excel (XlsIO) library. platform: document-processing control: XlsIO documentation: UG @@ -8,16 +8,18 @@ documentation: UG # CSV to Excel Conversion -XlsIO supports converting CSV data to Excel files by saving the workbook using the [SaveAs](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IWorkbook.html#Syncfusion_XlsIO_IWorkbook_SaveAs_System_IO_Stream_) method. When opening a CSV file, users can specify various delimiters to structure the data appropriately. +XlsIO can read a CSV file with [`IWorkbooks.Open`](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IWorkbooks.html#Syncfusion_XlsIO_IWorkbooks_Open_System_String_System_String_) and write the result to an Excel workbook with [`IWorkbook.SaveAs`](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IWorkbook.html#Syncfusion_XlsIO_IWorkbook_SaveAs_System_String_). The default delimiter when opening a CSV is a comma (`,`). To read other delimited formats, pass the matching character to the `Open` overload. -**Delimiters Used in CSV files** +N> IMPORTANT: Before running the samples on this page, install the required NuGet package for your target platform and register your Syncfusion license key. For more information, see the [Licensing overview](https://help.syncfusion.com/document-processing/licensing/overview). -* Comma (,) -* Tab (\t) -* Semicolon (;) -* Colon (:) -* Space ( ) -* Equals Sign (=) +The supported delimiters are: + +* **Comma** (`,`) — the default. +* **Tab** (`\t`) — used to open a TSV file. +* **Semicolon** (`;`) +* **Colon** (`:`) +* **Space** (` `) +* **Equals** (`=`) — used by some locales that export with leading `=` on every value; not a true separator. Use a different delimiter (for example `,` or `;`) and add a quote/unescape step in your own code. The following code example illustrates how to convert a CSV to an Excel file. @@ -52,7 +54,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -Using excelEngine As ExcelEngine = New ExcelEngine() +Using excelEngine As New ExcelEngine() Dim application As IApplication = excelEngine.Excel application.DefaultVersion = ExcelVersion.Xlsx @@ -63,12 +65,14 @@ Using excelEngine As ExcelEngine = New ExcelEngine() workbook.SaveAs("Output.xlsx") End Using {% endhighlight %} -{% endtabs %} +{% endtabs %} A complete working example to convert CSV to an Excel file in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/CSV%20to%20Excel/CSV%20to%20Excel/.NET/CSV%20to%20Excel). ## TSV to Excel Conversion +**TSV (Tab-Separated Values)** files are loaded by passing the tab character (`\t` in C#, `vbTab` in VB.NET) as the delimiter to `Workbooks.Open`. The workbook is then written to `.xlsx` with `SaveAs`. + The following code example illustrates how to convert a TSV to an Excel file. {% tabs %} @@ -108,10 +112,18 @@ Using excelEngine As New ExcelEngine() ' Open the TSV file Dim workbook As IWorkbook = application.Workbooks.Open("InputTemplate.tsv", vbTab) - ' Save in workbook + ' Saving the workbook workbook.SaveAs("Output.xlsx") End Using {% endhighlight %} -{% endtabs %} +{% endtabs %} -A complete working example to convert TSV to an Excel file in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/TSV%20to%20Excel/TSV%20to%20Excel/.NET/TSV%20to%20Excel). \ No newline at end of file +A complete working example to convert TSV to an Excel file in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/TSV%20to%20Excel/TSV%20to%20Excel/.NET/TSV%20to%20Excel). + +## See also + +* [Convert Excel to CSV (or TSV)](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-csv/overview) +* [Convert Excel to PDF](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-pdf/overview) +* [Convert Excel to image](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-image/overview) +* [NuGet packages for Excel (XlsIO)](https://help.syncfusion.com/document-processing/excel/getting-started/nuget-packages-required) +* [Syncfusion .NET Excel (XlsIO) — Licensing overview](https://help.syncfusion.com/document-processing/licensing/overview) \ No newline at end of file diff --git a/Document-Processing/Excel/Conversions/Chart-to-Image/NET/Chart-to-Image-Conversion.md b/Document-Processing/Excel/Conversions/Chart-to-Image/NET/Chart-to-Image-Conversion.md index 68fe0d1951..28e5737904 100644 --- a/Document-Processing/Excel/Conversions/Chart-to-Image/NET/Chart-to-Image-Conversion.md +++ b/Document-Processing/Excel/Conversions/Chart-to-Image/NET/Chart-to-Image-Conversion.md @@ -1,25 +1,32 @@ --- title: Chart to Image Conversion | Syncfusion -description: This section explains about Chart to Image conversion supported in XlsIO. Use XlsIORenderer class ChartRenderingOptions for specify Image format & quality. +description: This section explains how to convert an Excel chart to an image in XlsIO. Use XlsIORenderer.ChartRenderingOptions to set the image format and quality. platform: document-processing control: XlsIO documentation: UG --- -# Chart to image conversion +# Chart to Image Conversion -Refer to the following links for assemblies/nuget packages required based on platforms to convert the chart to image. +XlsIO exposes two API surfaces for converting an Excel chart to an image: -* [Assemblies Information](https://help.syncfusion.com/document-processing/excel/excel-library/net/assemblies-required#converting-excel-chart-to-image) +* **`XlsIORenderer`** — the cross-platform / .NET Standard API. Use this for ASP.NET Core, Blazor, WinUI, and .NET MAUI apps. +* **`ChartToImageConverter`** — the Windows-specific / .NET Framework API. Provides additional chart-quality settings through `ScalingMode`. + +Refer to the following links for the assemblies and NuGet packages required to convert a chart to an image, per platform: + +* [Assemblies Information](https://help.syncfusion.com/document-processing/excel/excel-library/net/assemblies-required#converting-excel-chart-to-image) * [NuGet Information](https://help.syncfusion.com/document-processing/excel/excel-library/net/nuget-packages-required#converting-charts-in-xlsio) -The following code snippet shows how to convert an Excel chart to an image using the [ChartToImageConverter](https://help.syncfusion.com/cr/document-processing/Syncfusion.ExcelChartToImageConverter.ChartToImageConverter.html) class. +N> IMPORTANT: Before running the samples on this page, install the required NuGet package for your target platform and register your Syncfusion license key. For more information, see the [Licensing overview](https://help.syncfusion.com/document-processing/licensing/overview). + +The following code snippets show how to convert an Excel chart to an image using `XlsIORenderer` (cross-platform) or [`ChartToImageConverter`](https://help.syncfusion.com/cr/document-processing/Syncfusion.ExcelChartToImageConverter.ChartToImageConverter.html) (Windows-specific). {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/XlsIO-Examples/master/Chart%20to%20Image/Chart%20to%20Image/.NET/Chart%20to%20Image/Chart%20to%20Image/Program.cs,180" %} using (ExcelEngine excelEngine = new ExcelEngine()) { - //Initialize application + //Initialize application IApplication application = excelEngine.Excel; //Set the default version as Xlsx @@ -35,22 +42,22 @@ using (ExcelEngine excelEngine = new ExcelEngine()) application.XlsIORenderer.ChartRenderingOptions.ScalingMode = ScalingMode.Best; //Open existing workbook with chart - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); - IWorksheet worksheet = workbook.Worksheets[0]; - - //Access the chart from the worksheet - IChart chart = worksheet.Charts[0]; - - #region Save - //Exporting the chart as image - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Image.png"), FileMode.Create, FileAccess.Write); - chart.SaveAsImage(outputStream); - #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); + using (FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read)) + { + IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorksheet worksheet = workbook.Worksheets[0]; + + //Access the chart from the worksheet + IChart chart = worksheet.Charts[0]; + + #region Save + //Exporting the chart as image + using (FileStream outputStream = new FileStream(Path.GetFullPath("Output/Image.png"), FileMode.Create, FileAccess.Write)) + { + chart.SaveAsImage(outputStream); + } + #endregion + } } {% endhighlight %} @@ -67,15 +74,19 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IWorksheet worksheet = workbook.Worksheets[0]; IChart chart = worksheet.Charts[0]; - //Creating the memory stream for chart image - MemoryStream stream = new MemoryStream(); - - //Saving the chart as image - chart.SaveAsImage(stream); - Image image = Image.FromStream(stream); - - //Saving image stream to file - image.Save("Output.png"); + // Create the memory stream for the chart image. + using (MemoryStream stream = new MemoryStream()) + { + chart.SaveAsImage(stream); + using (Image image = Image.FromStream(stream)) + { + // Persist the rendered chart to disk. + image.Save("Output.png"); + } + } + + // Alternatively, write directly to disk: + // chart.SaveAsImage("Output.png"); } {% endhighlight %} @@ -84,28 +95,30 @@ Using excelEngine As ExcelEngine = New ExcelEngine() Dim application As IApplication = excelEngine.Excel application.DefaultVersion = ExcelVersion.Xlsx - Dim ChartToImageConverter As chartToImageConverter = New ChartToImageConverter() - application.ChartToImageConverter = ChartToImageConverter + Dim chartConverter As New ChartToImageConverter() + application.ChartToImageConverter = chartConverter application.ChartToImageConverter.ScalingMode = ScalingMode.Best Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx") Dim worksheet As IWorksheet = workbook.Worksheets(0) Dim chart As IChart = worksheet.Charts(0) - 'Creating the memory stream for chart image - Dim stream As New MemoryStream() - - 'Saving the chart as image - chart.SaveAsImage(stream) - Dim image As Image = Image.FromStream(stream) - - 'Saving image stream to file - image.Save("Output.png") + ' Create the memory stream for the chart image. + Using stream As New MemoryStream() + chart.SaveAsImage(stream) + Using image As Image = Image.FromStream(stream) + ' Persist the rendered chart to disk. + image.Save("Output.png") + End Using + End Using + + ' Alternatively, write directly to disk: + ' chart.SaveAsImage("Output.png") End Using {% endhighlight %} -{% endtabs %} +{% endtabs %} -A complete working example to convert Excel chart to image in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Chart%20to%20Image/Chart%20to%20Image/.NET/Chart%20to%20Image). +A complete working example to convert an Excel chart to an image in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Chart%20to%20Image/Chart%20to%20Image/.NET/Chart%20to%20Image). N> 1. Instance of [XlsIORenderer](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.XlsIORenderer.XlsIORenderer.html) class is mandatory to convert the chart to image using .NET Standard 2.0 assemblies. N> 2. In .NET Standard, the Image format and quality can be specified using the [ChartRenderingOptions](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.XlsIORenderer.XlsIORenderer.html#Syncfusion_XlsIORenderer_XlsIORenderer_ChartRenderingOptions) property of XlsIORenderer class. By default the [ImageFormat](https://help.syncfusion.com/cr/document-processing/Syncfusion.Drawing.ImageFormat.html) for chart is set to JPEG and [ScalingMode](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.ScalingMode.html) is set to Best. @@ -270,4 +283,10 @@ XlsIO supports the following chart elements in image conversion: 6. Legend 7. Trend line -N> Rendering of charts from Excel document to PDF is performed using our own chart library. As a result, there might be some preservation differences, and the output chart in PDF may not exactly match the chart in Microsoft Excel. +N> NOTE: Rendering of charts from Excel documents to images (and to PDF) uses Syncfusion's own chart rendering engine. As a result, the output may not exactly match the chart in Microsoft Excel; minor differences in spacing, colors, and font metrics may occur. + +## See also + +* [Excel to PDF conversion guide](../..//Excel-to-PDF/NET/excel-to-pdf-conversion) — chart-to-PDF rendering uses the same `ChartToImageConverter` internally. +* [Worksheet to Image conversion](../..//Excel-to-Image/NET/worksheet-to-image-conversion) — full worksheet rendering as PNG and other formats. +* [Licensing overview](https://help.syncfusion.com/document-processing/licensing/overview) — register your license key. diff --git a/Document-Processing/Excel/Conversions/Chart-to-Image/overview.md b/Document-Processing/Excel/Conversions/Chart-to-Image/overview.md index 6e5312497e..e797a482dc 100644 --- a/Document-Processing/Excel/Conversions/Chart-to-Image/overview.md +++ b/Document-Processing/Excel/Conversions/Chart-to-Image/overview.md @@ -1,6 +1,6 @@ --- title: Syncfusion Chart to Image Conversion using XlsIO | Syncfusion -description: This page explains about how to convert charts from Excel documents to images using XlsIO. It allows to specify the image quality and format. +description: This page explains how to convert Excel charts to images using XlsIO. You can set the image quality and format. platform: document-processing control: XlsIO documentation: UG @@ -8,12 +8,19 @@ documentation: UG # Chart to Image Conversion in XlsIO -Refer to the following links for assemblies/nuget packages required based on platforms to convert the chart to image. +XlsIO exposes two API surfaces for converting an Excel chart to an image: -* [Assemblies Information](https://help.syncfusion.com/document-processing/excel/excel-library/net/assemblies-required#converting-excel-chart-to-image) +* **`XlsIORenderer`** — the cross-platform / .NET Standard API. Use this for ASP.NET Core, Blazor, WinUI, and .NET MAUI apps. +* **`ChartToImageConverter`** — the Windows-specific / .NET Framework API. Provides additional chart-quality settings through `ScalingMode`. + +Refer to the following links for the assemblies and NuGet packages required to convert a chart to an image, per platform: + +* [Assemblies Information](https://help.syncfusion.com/document-processing/excel/excel-library/net/assemblies-required#converting-excel-chart-to-image) * [NuGet Information](https://help.syncfusion.com/document-processing/excel/excel-library/net/nuget-packages-required#converting-charts-in-xlsio) -The following code snippet shows how to convert an Excel chart to an image using the [ChartToImageConverter](https://help.syncfusion.com/cr/document-processing/Syncfusion.ExcelChartToImageConverter.ChartToImageConverter.html) class. +N> IMPORTANT: Before running the samples on this page, install the required NuGet package for your target platform and register your Syncfusion license key. For more information, see the [Licensing overview](https://help.syncfusion.com/document-processing/licensing/overview). + +The following code snippets show how to convert an Excel chart to an image using `XlsIORenderer` (cross-platform) or [`ChartToImageConverter`](https://help.syncfusion.com/cr/document-processing/Syncfusion.ExcelChartToImageConverter.ChartToImageConverter.html) (Windows-specific). {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/XlsIO-Examples/master/Chart%20to%20Image/Chart%20to%20Image/.NET/Chart%20to%20Image/Chart%20to%20Image/Program.cs,180" %} @@ -22,25 +29,19 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - // Initialize XlsIORenderer + // Initialize XlsIORenderer and set the chart image format to PNG. application.XlsIORenderer = new XlsIORenderer(); - - //Set converter chart image format to PNG application.XlsIORenderer.ChartRenderingOptions.ImageFormat = ExportImageFormat.Png; IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); IWorksheet worksheet = workbook.Worksheets[0]; - IChart chart = worksheet.Charts[0]; - #region Save - //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Image.png"), FileMode.Create, FileAccess.Write); - chart.SaveAsImage(outputStream); - #endregion - - //Dispose streams - outputStream.Dispose(); + // Save the chart as a PNG image. + using (FileStream outputStream = new FileStream(Path.GetFullPath("Output/Image.png"), FileMode.Create, FileAccess.Write)) + { + chart.SaveAsImage(outputStream); + } } {% endhighlight %} @@ -57,15 +58,19 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IWorksheet worksheet = workbook.Worksheets[0]; IChart chart = worksheet.Charts[0]; - //Creating the memory stream for chart image - MemoryStream stream = new MemoryStream(); + // Create the memory stream for the chart image. + using (MemoryStream stream = new MemoryStream()) + { + chart.SaveAsImage(stream); + using (Image image = Image.FromStream(stream)) + { + // Persist the rendered chart to disk. + image.Save("Output.png"); + } + } - //Saving the chart as image - chart.SaveAsImage(stream); - Image image = Image.FromStream(stream); - - //Saving image stream to file - image.Save("Output.png"); + // Alternatively, write directly to disk: + // chart.SaveAsImage("Output.png"); } {% endhighlight %} @@ -74,28 +79,30 @@ Using excelEngine As ExcelEngine = New ExcelEngine() Dim application As IApplication = excelEngine.Excel application.DefaultVersion = ExcelVersion.Xlsx - Dim ChartToImageConverter As chartToImageConverter = New ChartToImageConverter() - application.ChartToImageConverter = ChartToImageConverter + Dim chartConverter As New ChartToImageConverter() + application.ChartToImageConverter = chartConverter application.ChartToImageConverter.ScalingMode = ScalingMode.Best Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx") Dim worksheet As IWorksheet = workbook.Worksheets(0) Dim chart As IChart = worksheet.Charts(0) - 'Creating the memory stream for chart image - Dim stream As New MemoryStream() - - 'Saving the chart as image - chart.SaveAsImage(stream) - Dim image As Image = Image.FromStream(stream) + ' Create the memory stream for the chart image. + Using stream As New MemoryStream() + chart.SaveAsImage(stream) + Using image As Image = Image.FromStream(stream) + ' Persist the rendered chart to disk. + image.Save("Output.png") + End Using + End Using - 'Saving image stream to file - image.Save("Output.png") + ' Alternatively, write directly to disk: + ' chart.SaveAsImage("Output.png") End Using {% endhighlight %} -{% endtabs %} +{% endtabs %} -A complete working example to convert Excel chart to image in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Chart%20to%20Image/Chart%20to%20Image/.NET/Chart%20to%20Image). +A complete working example to convert an Excel chart to an image in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Chart%20to%20Image/Chart%20to%20Image/.NET/Chart%20to%20Image). N> 1. Instance of [XlsIORenderer](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.XlsIORenderer.XlsIORenderer.html) class is mandatory to convert the chart to image using .NET Standard 2.0 assemblies. N> 2. In .NET Standard, the Image format and quality can be specified using the [ChartRenderingOptions](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.XlsIORenderer.XlsIORenderer.html#Syncfusion_XlsIORenderer_XlsIORenderer_ChartRenderingOptions) property of XlsIORenderer class. By default the [ImageFormat](https://help.syncfusion.com/cr/document-processing/Syncfusion.Drawing.ImageFormat.html) for chart is set to JPEG and [ScalingMode](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.ScalingMode.html) is set to Best. diff --git a/Document-Processing/Excel/Conversions/Excel-to-CSV/NET/Excel-to-CSV-Conversion.md b/Document-Processing/Excel/Conversions/Excel-to-CSV/NET/Excel-to-CSV-Conversion.md index 4355e1e599..36e0266ea3 100644 --- a/Document-Processing/Excel/Conversions/Excel-to-CSV/NET/Excel-to-CSV-Conversion.md +++ b/Document-Processing/Excel/Conversions/Excel-to-CSV/NET/Excel-to-CSV-Conversion.md @@ -1,6 +1,6 @@ --- title: Syncfusion Excel to CSV Conversion -description: In this section, you can learn how to convert Excel docuemnt to CSV document using Syncfusion Essential XlsIO. +description: Lists how to convert an Excel workbook to a CSV (or TSV) document using the Syncfusion .NET Excel (XlsIO) library. platform: document-processing control: XlsIO documentation: UG @@ -8,16 +8,18 @@ documentation: UG # Excel to CSV Conversion -XlsIO supports converting Excel file to CSV file by saving the workbook using the [SaveAs](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IWorksheet.html#Syncfusion_XlsIO_IWorksheet_SaveAs_System_IO_Stream_System_String_) method. When saving as CSV, users can specify various delimiters to structure the data appropriately. By default, Syncfusion® XlsIO uses a comma (,) as the delimiter. +XlsIO can convert an Excel workbook to a CSV file by saving the workbook with the [`SaveAs`](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IWorkbook.html#Syncfusion_XlsIO_IWorkbook_SaveAs_System_String_System_String_) overload that accepts a delimiter string. The default delimiter is a comma (`,`). -**Delimiters Used in CSV files** +N> IMPORTANT: Before running the samples on this page, install the required NuGet package for your target platform and register your Syncfusion license key. For more information, see the [Licensing overview](https://help.syncfusion.com/document-processing/licensing/overview). -* Comma (,) -* Tab (\t) -* Semicolon (;) -* Colon (:) -* Space ( ) -* Equals Sign (=) +The supported delimiters are: + +* **Comma** (`,`) — the default. +* **Tab** (`\t`) — produces a TSV file. +* **Semicolon** (`;`) +* **Colon** (`:`) +* **Space** (` `) +* **Equals** (`=`) — prefixes cells that begin with `=`, `+`, `-`, or `@` with a single quote so they are not interpreted as formulas when opened in a spreadsheet program. This is the recommended setting when exporting to a CSV that may be re-imported. The following code example illustrates how to convert an Excel file to CSV. @@ -53,19 +55,19 @@ Using excelEngine As New ExcelEngine() Dim workbook As IWorkbook = application.Workbooks.Open("InputTemplate.xlsx") ' Saving the workbook - worksheet.SaveAs("Output.csv", ",") + workbook.SaveAs("Output.csv", ",") End Using {% endhighlight %} -{% endtabs %} +{% endtabs %} A complete working example to convert an Excel file to CSV in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Excel%20to%20CSV/Excel%20to%20CSV/.NET/Excel%20to%20CSV). -**Maximum Rows and Columns for CSV** +## Maximum Rows and Columns for CSV -By default, XlsIO allows only 1048576 rows and 16256 columns while loading or saving a CSV document. This limit can be increased by modifying the [MaximumRowsForCsv](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IApplication.html#Syncfusion_XlsIO_IApplication_MaximumRowsForCsv) and [MaximumColumnsForCsv](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IApplication.html#Syncfusion_XlsIO_IApplication_MaximumColumnsForCsv) properties. +By default, XlsIO allows up to **1,048,576 rows and 16,256 columns** when loading or saving a CSV document. Exceeding these limits throws `ArgumentOutOfRangeException`. Increase them by setting [`MaximumRowsForCsv`](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IApplication.html#Syncfusion_XlsIO_IApplication_MaximumRowsForCsv) and [`MaximumColumnsForCsv`](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IApplication.html#Syncfusion_XlsIO_IApplication_MaximumColumnsForCsv) on `IApplication`. The properties affect loading as well as saving, so they apply whether the input is an `.xlsx` file or another `.csv`. -The following code example illustrates how to set the maximum rows and columns for saving as CSV files. +The following code example illustrates how to override the load/ save limits and convert a workbook to CSV. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} @@ -83,8 +85,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) sheet.Range[2000000, 1].Text = "Syncfusion"; sheet.Range[20, 18000].Text = "Syncfusion"; - //Saving the workbook - workbook.SaveAs("Output.csv",","); + // Saving the workbook + workbook.SaveAs("Output.csv", ","); } {% endhighlight %} @@ -103,13 +105,13 @@ using (ExcelEngine excelEngine = new ExcelEngine()) sheet.Range[2000000, 1].Text = "Syncfusion"; sheet.Range[20, 18000].Text = "Syncfusion"; - //Saving the workbook + // Saving the workbook workbook.SaveAs("Output.csv", ","); } {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -Using excelEngine As ExcelEngine = New ExcelEngine() +Using excelEngine As New ExcelEngine() Dim application As IApplication = excelEngine.Excel application.DefaultVersion = ExcelVersion.Xlsx @@ -122,7 +124,7 @@ Using excelEngine As ExcelEngine = New ExcelEngine() sheet.Range(2000000, 1).Text = "Syncfusion" sheet.Range(20, 18000).Text = "Syncfusion" - //Saving the workbook + ' Saving the workbook workbook.SaveAs("Output.csv", ",") End Using {% endhighlight %} @@ -130,7 +132,7 @@ End Using ## Excel to TSV Conversion -TSV (Tab-Separated Values) files can be created by saving a workbook with the tab separator (\t). +**TSV (Tab-Separated Values)** files can be created by saving a workbook with the tab character (`\t` in C#, `vbTab` in VB.NET) as the delimiter. The following code example illustrates how to convert an Excel file to TSV. @@ -173,3 +175,11 @@ End Using {% endtabs %} A complete working example to convert an Excel file to TSV in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Excel%20to%20TSV/Excel%20to%20TSV/.NET/Excel%20to%20TSV). + +## See also + +* [Save a workbook in CSV, TSV, or other delimited formats](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-csv/overview) +* [Convert Excel to PDF](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-pdf/overview) +* [Convert Excel to image](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-image/overview) +* [NuGet packages for Excel (XlsIO)](https://help.syncfusion.com/document-processing/excel/getting-started/nuget-packages-required) +* [Syncfusion .NET Excel (XlsIO) — Licensing overview](https://help.syncfusion.com/document-processing/licensing/overview) diff --git a/Document-Processing/Excel/Conversions/Excel-to-CSV/overview.md b/Document-Processing/Excel/Conversions/Excel-to-CSV/overview.md index 4355e1e599..36e0266ea3 100644 --- a/Document-Processing/Excel/Conversions/Excel-to-CSV/overview.md +++ b/Document-Processing/Excel/Conversions/Excel-to-CSV/overview.md @@ -1,6 +1,6 @@ --- title: Syncfusion Excel to CSV Conversion -description: In this section, you can learn how to convert Excel docuemnt to CSV document using Syncfusion Essential XlsIO. +description: Lists how to convert an Excel workbook to a CSV (or TSV) document using the Syncfusion .NET Excel (XlsIO) library. platform: document-processing control: XlsIO documentation: UG @@ -8,16 +8,18 @@ documentation: UG # Excel to CSV Conversion -XlsIO supports converting Excel file to CSV file by saving the workbook using the [SaveAs](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IWorksheet.html#Syncfusion_XlsIO_IWorksheet_SaveAs_System_IO_Stream_System_String_) method. When saving as CSV, users can specify various delimiters to structure the data appropriately. By default, Syncfusion® XlsIO uses a comma (,) as the delimiter. +XlsIO can convert an Excel workbook to a CSV file by saving the workbook with the [`SaveAs`](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IWorkbook.html#Syncfusion_XlsIO_IWorkbook_SaveAs_System_String_System_String_) overload that accepts a delimiter string. The default delimiter is a comma (`,`). -**Delimiters Used in CSV files** +N> IMPORTANT: Before running the samples on this page, install the required NuGet package for your target platform and register your Syncfusion license key. For more information, see the [Licensing overview](https://help.syncfusion.com/document-processing/licensing/overview). -* Comma (,) -* Tab (\t) -* Semicolon (;) -* Colon (:) -* Space ( ) -* Equals Sign (=) +The supported delimiters are: + +* **Comma** (`,`) — the default. +* **Tab** (`\t`) — produces a TSV file. +* **Semicolon** (`;`) +* **Colon** (`:`) +* **Space** (` `) +* **Equals** (`=`) — prefixes cells that begin with `=`, `+`, `-`, or `@` with a single quote so they are not interpreted as formulas when opened in a spreadsheet program. This is the recommended setting when exporting to a CSV that may be re-imported. The following code example illustrates how to convert an Excel file to CSV. @@ -53,19 +55,19 @@ Using excelEngine As New ExcelEngine() Dim workbook As IWorkbook = application.Workbooks.Open("InputTemplate.xlsx") ' Saving the workbook - worksheet.SaveAs("Output.csv", ",") + workbook.SaveAs("Output.csv", ",") End Using {% endhighlight %} -{% endtabs %} +{% endtabs %} A complete working example to convert an Excel file to CSV in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Excel%20to%20CSV/Excel%20to%20CSV/.NET/Excel%20to%20CSV). -**Maximum Rows and Columns for CSV** +## Maximum Rows and Columns for CSV -By default, XlsIO allows only 1048576 rows and 16256 columns while loading or saving a CSV document. This limit can be increased by modifying the [MaximumRowsForCsv](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IApplication.html#Syncfusion_XlsIO_IApplication_MaximumRowsForCsv) and [MaximumColumnsForCsv](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IApplication.html#Syncfusion_XlsIO_IApplication_MaximumColumnsForCsv) properties. +By default, XlsIO allows up to **1,048,576 rows and 16,256 columns** when loading or saving a CSV document. Exceeding these limits throws `ArgumentOutOfRangeException`. Increase them by setting [`MaximumRowsForCsv`](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IApplication.html#Syncfusion_XlsIO_IApplication_MaximumRowsForCsv) and [`MaximumColumnsForCsv`](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IApplication.html#Syncfusion_XlsIO_IApplication_MaximumColumnsForCsv) on `IApplication`. The properties affect loading as well as saving, so they apply whether the input is an `.xlsx` file or another `.csv`. -The following code example illustrates how to set the maximum rows and columns for saving as CSV files. +The following code example illustrates how to override the load/ save limits and convert a workbook to CSV. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} @@ -83,8 +85,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) sheet.Range[2000000, 1].Text = "Syncfusion"; sheet.Range[20, 18000].Text = "Syncfusion"; - //Saving the workbook - workbook.SaveAs("Output.csv",","); + // Saving the workbook + workbook.SaveAs("Output.csv", ","); } {% endhighlight %} @@ -103,13 +105,13 @@ using (ExcelEngine excelEngine = new ExcelEngine()) sheet.Range[2000000, 1].Text = "Syncfusion"; sheet.Range[20, 18000].Text = "Syncfusion"; - //Saving the workbook + // Saving the workbook workbook.SaveAs("Output.csv", ","); } {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -Using excelEngine As ExcelEngine = New ExcelEngine() +Using excelEngine As New ExcelEngine() Dim application As IApplication = excelEngine.Excel application.DefaultVersion = ExcelVersion.Xlsx @@ -122,7 +124,7 @@ Using excelEngine As ExcelEngine = New ExcelEngine() sheet.Range(2000000, 1).Text = "Syncfusion" sheet.Range(20, 18000).Text = "Syncfusion" - //Saving the workbook + ' Saving the workbook workbook.SaveAs("Output.csv", ",") End Using {% endhighlight %} @@ -130,7 +132,7 @@ End Using ## Excel to TSV Conversion -TSV (Tab-Separated Values) files can be created by saving a workbook with the tab separator (\t). +**TSV (Tab-Separated Values)** files can be created by saving a workbook with the tab character (`\t` in C#, `vbTab` in VB.NET) as the delimiter. The following code example illustrates how to convert an Excel file to TSV. @@ -173,3 +175,11 @@ End Using {% endtabs %} A complete working example to convert an Excel file to TSV in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Excel%20to%20TSV/Excel%20to%20TSV/.NET/Excel%20to%20TSV). + +## See also + +* [Save a workbook in CSV, TSV, or other delimited formats](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-csv/overview) +* [Convert Excel to PDF](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-pdf/overview) +* [Convert Excel to image](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-image/overview) +* [NuGet packages for Excel (XlsIO)](https://help.syncfusion.com/document-processing/excel/getting-started/nuget-packages-required) +* [Syncfusion .NET Excel (XlsIO) — Licensing overview](https://help.syncfusion.com/document-processing/licensing/overview) diff --git a/Document-Processing/Excel/Conversions/Excel-to-HTML/NET/Excel-to-HTML-Conversion.md b/Document-Processing/Excel/Conversions/Excel-to-HTML/NET/Excel-to-HTML-Conversion.md index 4d65e08c3f..ad3938f06d 100644 --- a/Document-Processing/Excel/Conversions/Excel-to-HTML/NET/Excel-to-HTML-Conversion.md +++ b/Document-Processing/Excel/Conversions/Excel-to-HTML/NET/Excel-to-HTML-Conversion.md @@ -1,6 +1,6 @@ --- title: Syncfusion Excel to HTML Conversion -description: In this section, you can learn how to convert Excel docuemnt to HTML document using Syncfusion Essential XlsIO. +description: Lists how to convert an Excel workbook or worksheet to HTML using the Syncfusion .NET Excel (XlsIO) library. platform: document-processing control: XlsIO documentation: UG @@ -8,7 +8,7 @@ documentation: UG # Excel to HTML Conversion -XlsIO provides support to convert a worksheet or entire workbook to HTML with basic formatting preserved. The supporting formats in this conversion are: +XlsIO converts a worksheet or an entire workbook to HTML while preserving basic formatting. The features preserved during conversion are: * Styles * Hyperlinks @@ -21,22 +21,16 @@ The following code example illustrates how to convert an Excel file to HTML. {% highlight c# tabtitle="C# [Cross-platform]" %} using (ExcelEngine excelEngine = new ExcelEngine()) { - //Initialize excel engine and open workbook + // Initialize Excel engine and create a new workbook IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; IWorkbook workbook = application.Workbooks.Create(1); IWorksheet worksheet = workbook.Worksheets[0]; worksheet.Range["A1:M20"].Text = "Html Document"; - //Create stream to store HTML file. - Stream stream = new MemoryStream(); - - //Save an Excel sheet as HTML file - worksheet.SaveAsHtml(stream); - - //Save a workbook as HTML file + // Save a workbook as HTML file workbook.SaveAsHtml("Sample.html", Syncfusion.XlsIO.Implementation.HtmlSaveOptions.Default); - stream.Dispose(); + workbook.Close(); } {% endhighlight %} @@ -50,32 +44,26 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IWorksheet sheet = workbook.Worksheets[0]; sheet.Range["A1:M20"].Text = "Html Document"; - //Save an Excel sheet as HTML file - sheet.SaveAsHtml("Sample.html"); - - //Save the workbook as HTML file + // Save a workbook as HTML file workbook.SaveAsHtml("Sample.html", Syncfusion.XlsIO.Implementation.HtmlSaveOptions.Default); } {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -Using excelEngine As ExcelEngine = New ExcelEngine() +Using excelEngine As New ExcelEngine() Dim application As IApplication = excelEngine.Excel application.DefaultVersion = ExcelVersion.Xlsx Dim workbook As IWorkbook = application.Workbooks.Create(1) Dim sheet As IWorksheet = workbook.Worksheets(0) sheet.Range("A1:M20").Text = "Html Document" - 'Save an Excel sheet as HTML file - sheet.SaveAsHtml("Sample.html") - - 'Save a workbook as HTML file + ' Save a workbook as HTML file workbook.SaveAsHtml("Sample.html", Syncfusion.XlsIO.Implementation.HtmlSaveOptions.Default) End Using {% endhighlight %} {% endtabs %} -## Save Options +## HtmlSaveOptions XlsIO also provides options to save a worksheet with the displayed text or value in the cell to HTML file. The following code example illustrates this. @@ -83,22 +71,20 @@ XlsIO also provides options to save a worksheet with the displayed text or value {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/XlsIO-Examples/master/Excel%20to%20HTML/Excel%20to%20HTML/.NET/Excel%20to%20HTML/Excel%20to%20HTML/Program.cs,180" %} using (ExcelEngine excelEngine = new ExcelEngine()) { - //Initialize excel engine and open workbook + // Initialize Excel engine and create a new workbook IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; IWorkbook workbook = application.Workbooks.Create(1); IWorksheet worksheet = workbook.Worksheets[0]; worksheet.Range["A1:M20"].Text = "Html Document"; + worksheet.UsedRange.AutofitColumns(); - //Create the instant for SaveOptions + // Create the instance of SaveOptions HtmlSaveOptions saveOptions = new HtmlSaveOptions(); saveOptions.TextMode = HtmlSaveOptions.GetText.DisplayText; - worksheet.UsedRange.AutofitColumns(); - #region Save as HTML - //Saving the workbook + // Save the workbook as HTML workbook.SaveAsHtml(Path.GetFullPath("Output/Output.html"), saveOptions); - #endregion } {% endhighlight %} @@ -110,37 +96,42 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IWorkbook workbook = application.Workbooks.Create(1); IWorksheet sheet = workbook.Worksheets[0]; - //Create the instant for SaveOptions + // Create the instance of SaveOptions HtmlSaveOptions options = new HtmlSaveOptions(); options.TextMode = HtmlSaveOptions.GetText.DisplayText; options.ImagePath = "../../Images/"; - //Save the sheet as HTML + // Save the sheet as HTML sheet.SaveAsHtml("Sample.html", options); - - workbook.SaveAs("Output.xlsx"); } {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -Using excelEngine As ExcelEngine = New ExcelEngine() +Using excelEngine As New ExcelEngine() Dim application As IApplication = excelEngine.Excel application.DefaultVersion = ExcelVersion.Xlsx Dim workbook As IWorkbook = application.Workbooks.Create(1) Dim sheet As IWorksheet = workbook.Worksheets(0) - 'Create the instant for SaveOptions + ' Create the instance of SaveOptions Dim options As New HtmlSaveOptions() options.TextMode = HtmlSaveOptions.GetText.DisplayText options.ImagePath = "../../Images/" - 'Save the sheet as HTML + ' Save the sheet as HTML sheet.SaveAsHtml("Sample.html", options) - - workbook.SaveAs("Output.xlsx") End Using {% endhighlight %} {% endtabs %} A complete working example to save an Excel worksheet as HTML file using [HtmlSaveOptions](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.Implementation.HtmlSaveOptions.html) in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Excel%20to%20HTML/Excel%20to%20HTML/.NET/Excel%20to%20HTML). +## See also + +* [Convert Excel to PDF](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-pdf/overview) +* [Convert Excel to image](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-image/overview) +* [Convert Excel to CSV (or TSV)](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-csv/overview) +* [Convert a chart to an image](https://help.syncfusion.com/document-processing/excel/conversions/chart-to-image/overview) +* [NuGet packages for Excel (XlsIO)](https://help.syncfusion.com/document-processing/excel/getting-started/nuget-packages-required) +* [Syncfusion .NET Excel (XlsIO) — Licensing overview](https://help.syncfusion.com/document-processing/licensing/overview) + diff --git a/Document-Processing/Excel/Conversions/Excel-to-HTML/overview.md b/Document-Processing/Excel/Conversions/Excel-to-HTML/overview.md index 4d65e08c3f..ad3938f06d 100644 --- a/Document-Processing/Excel/Conversions/Excel-to-HTML/overview.md +++ b/Document-Processing/Excel/Conversions/Excel-to-HTML/overview.md @@ -1,6 +1,6 @@ --- title: Syncfusion Excel to HTML Conversion -description: In this section, you can learn how to convert Excel docuemnt to HTML document using Syncfusion Essential XlsIO. +description: Lists how to convert an Excel workbook or worksheet to HTML using the Syncfusion .NET Excel (XlsIO) library. platform: document-processing control: XlsIO documentation: UG @@ -8,7 +8,7 @@ documentation: UG # Excel to HTML Conversion -XlsIO provides support to convert a worksheet or entire workbook to HTML with basic formatting preserved. The supporting formats in this conversion are: +XlsIO converts a worksheet or an entire workbook to HTML while preserving basic formatting. The features preserved during conversion are: * Styles * Hyperlinks @@ -21,22 +21,16 @@ The following code example illustrates how to convert an Excel file to HTML. {% highlight c# tabtitle="C# [Cross-platform]" %} using (ExcelEngine excelEngine = new ExcelEngine()) { - //Initialize excel engine and open workbook + // Initialize Excel engine and create a new workbook IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; IWorkbook workbook = application.Workbooks.Create(1); IWorksheet worksheet = workbook.Worksheets[0]; worksheet.Range["A1:M20"].Text = "Html Document"; - //Create stream to store HTML file. - Stream stream = new MemoryStream(); - - //Save an Excel sheet as HTML file - worksheet.SaveAsHtml(stream); - - //Save a workbook as HTML file + // Save a workbook as HTML file workbook.SaveAsHtml("Sample.html", Syncfusion.XlsIO.Implementation.HtmlSaveOptions.Default); - stream.Dispose(); + workbook.Close(); } {% endhighlight %} @@ -50,32 +44,26 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IWorksheet sheet = workbook.Worksheets[0]; sheet.Range["A1:M20"].Text = "Html Document"; - //Save an Excel sheet as HTML file - sheet.SaveAsHtml("Sample.html"); - - //Save the workbook as HTML file + // Save a workbook as HTML file workbook.SaveAsHtml("Sample.html", Syncfusion.XlsIO.Implementation.HtmlSaveOptions.Default); } {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -Using excelEngine As ExcelEngine = New ExcelEngine() +Using excelEngine As New ExcelEngine() Dim application As IApplication = excelEngine.Excel application.DefaultVersion = ExcelVersion.Xlsx Dim workbook As IWorkbook = application.Workbooks.Create(1) Dim sheet As IWorksheet = workbook.Worksheets(0) sheet.Range("A1:M20").Text = "Html Document" - 'Save an Excel sheet as HTML file - sheet.SaveAsHtml("Sample.html") - - 'Save a workbook as HTML file + ' Save a workbook as HTML file workbook.SaveAsHtml("Sample.html", Syncfusion.XlsIO.Implementation.HtmlSaveOptions.Default) End Using {% endhighlight %} {% endtabs %} -## Save Options +## HtmlSaveOptions XlsIO also provides options to save a worksheet with the displayed text or value in the cell to HTML file. The following code example illustrates this. @@ -83,22 +71,20 @@ XlsIO also provides options to save a worksheet with the displayed text or value {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/XlsIO-Examples/master/Excel%20to%20HTML/Excel%20to%20HTML/.NET/Excel%20to%20HTML/Excel%20to%20HTML/Program.cs,180" %} using (ExcelEngine excelEngine = new ExcelEngine()) { - //Initialize excel engine and open workbook + // Initialize Excel engine and create a new workbook IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; IWorkbook workbook = application.Workbooks.Create(1); IWorksheet worksheet = workbook.Worksheets[0]; worksheet.Range["A1:M20"].Text = "Html Document"; + worksheet.UsedRange.AutofitColumns(); - //Create the instant for SaveOptions + // Create the instance of SaveOptions HtmlSaveOptions saveOptions = new HtmlSaveOptions(); saveOptions.TextMode = HtmlSaveOptions.GetText.DisplayText; - worksheet.UsedRange.AutofitColumns(); - #region Save as HTML - //Saving the workbook + // Save the workbook as HTML workbook.SaveAsHtml(Path.GetFullPath("Output/Output.html"), saveOptions); - #endregion } {% endhighlight %} @@ -110,37 +96,42 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IWorkbook workbook = application.Workbooks.Create(1); IWorksheet sheet = workbook.Worksheets[0]; - //Create the instant for SaveOptions + // Create the instance of SaveOptions HtmlSaveOptions options = new HtmlSaveOptions(); options.TextMode = HtmlSaveOptions.GetText.DisplayText; options.ImagePath = "../../Images/"; - //Save the sheet as HTML + // Save the sheet as HTML sheet.SaveAsHtml("Sample.html", options); - - workbook.SaveAs("Output.xlsx"); } {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -Using excelEngine As ExcelEngine = New ExcelEngine() +Using excelEngine As New ExcelEngine() Dim application As IApplication = excelEngine.Excel application.DefaultVersion = ExcelVersion.Xlsx Dim workbook As IWorkbook = application.Workbooks.Create(1) Dim sheet As IWorksheet = workbook.Worksheets(0) - 'Create the instant for SaveOptions + ' Create the instance of SaveOptions Dim options As New HtmlSaveOptions() options.TextMode = HtmlSaveOptions.GetText.DisplayText options.ImagePath = "../../Images/" - 'Save the sheet as HTML + ' Save the sheet as HTML sheet.SaveAsHtml("Sample.html", options) - - workbook.SaveAs("Output.xlsx") End Using {% endhighlight %} {% endtabs %} A complete working example to save an Excel worksheet as HTML file using [HtmlSaveOptions](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.Implementation.HtmlSaveOptions.html) in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Excel%20to%20HTML/Excel%20to%20HTML/.NET/Excel%20to%20HTML). +## See also + +* [Convert Excel to PDF](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-pdf/overview) +* [Convert Excel to image](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-image/overview) +* [Convert Excel to CSV (or TSV)](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-csv/overview) +* [Convert a chart to an image](https://help.syncfusion.com/document-processing/excel/conversions/chart-to-image/overview) +* [NuGet packages for Excel (XlsIO)](https://help.syncfusion.com/document-processing/excel/getting-started/nuget-packages-required) +* [Syncfusion .NET Excel (XlsIO) — Licensing overview](https://help.syncfusion.com/document-processing/licensing/overview) + diff --git a/Document-Processing/Excel/Conversions/Excel-to-Image/NET/Worksheet-to-Image-Conversion.md b/Document-Processing/Excel/Conversions/Excel-to-Image/NET/Worksheet-to-Image-Conversion.md index 2dd85cdd46..b9332bf8e9 100644 --- a/Document-Processing/Excel/Conversions/Excel-to-Image/NET/Worksheet-to-Image-Conversion.md +++ b/Document-Processing/Excel/Conversions/Excel-to-Image/NET/Worksheet-to-Image-Conversion.md @@ -1,44 +1,51 @@ --- -title: Worksheet to Image conversion in Excel Library | Syncfusion -description: Learn here all about worksheet to image conversion feature of Syncfusion Excel (XlsIO) Library and more. +title: Worksheet to Image Conversion in Excel Library | Syncfusion +description: Learn how to convert an Excel worksheet to an image using the Syncfusion Excel (XlsIO) library. platform: document-processing control: XlsIO documentation: UG --- -# Worksheet to Image conversion in Excel Library +# Worksheet to Image Conversion in Excel Library ## Assemblies Required -Refer to the following links for assemblies/nuget packages required based on platforms to convert the worksheet to image. +Refer to the following links for the assemblies and NuGet packages required to convert a worksheet to an image, per platform: * [NuGet Information](https://help.syncfusion.com/document-processing/excel/excel-library/net/nuget-packages-required#converting-excel-worksheet-to-image) -N> Worksheet To Image conversion can be performed by referring [Syncfusion.XlsIORenderer.Net.Core](https://www.nuget.org/packages/Syncfusion.XlsIORenderer.Net.Core) NuGet package in UWP platform. +N> Worksheet-to-image conversion can be performed by referring to the [Syncfusion.XlsIORenderer.Net.Core](https://www.nuget.org/packages/Syncfusion.XlsIORenderer.Net.Core) NuGet package in UWP platform. ## Convert as bitmap -The following code shows how to convert the specified range of rows and columns in the worksheet to bitmap. +The following code shows how to convert a specified range of rows and columns in the worksheet to a bitmap image. The four integer parameters are `firstRow`, `firstColumn`, `lastRow`, and `lastColumn` (1-based). {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} +// The following snippet assumes `application` and `worksheet` are already initialized +// (see the "Complete code" tab below for the full setup). // Initialize XlsIORenderer application.XlsIORenderer = new XlsIORenderer(); -//Create a new memory stream to save the image -Stream stream = new MemoryStream(); - -//Convert worksheet to image and save it to stream. -worksheet.ConvertToImage(1, 1, 10, 20, stream); +// Create a new memory stream to save the image +using (Stream stream = new MemoryStream()) +{ + // Convert worksheet to image and save it to the stream. + worksheet.ConvertToImage(1, 1, 10, 20, stream); +} {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +// The following snippet assumes `sheet` is already initialized (see the +// "Complete code" tab below for the full setup). // Convert as bitmap Image image = sheet.ConvertToImage(1, 1, 10, 20); image.Save("Sample.png", ImageFormat.Png); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +'The following snippet assumes `sheet` is already initialized (see the +'"Complete code" tab below for the full setup). 'Convert as bitmap Dim image As Image = sheet.ConvertToImage(1, 1, 10, 20) image.Save("Sample.png", ImageFormat.Png) @@ -47,28 +54,35 @@ image.Save("Sample.png", ImageFormat.Png) ## Save as stream -The following code snippet shows how to save a sheet as stream. +The following code snippet shows how to save a sheet as a stream. On Windows, you can choose the output [ImageType](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.ImageType.html) (such as `Bitmap`, `Metafile`, or `EMF`); on .NET Standard the format is controlled by `ExportImageOptions` (see the [Customizing the output image](#customizing-the-output-image-exportimageoptions) section below). After `ConvertToImage(...)` writes to a stream, the stream's position is at the end; set `stream.Position = 0` if you need to read from it afterwards. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/XlsIO-Examples/master/Worksheet%20to%20Image/Worksheet%20to%20Image/.NET/Worksheet%20to%20Image/Worksheet%20to%20Image/Program.cs,180" %} +// The following snippet assumes `application` and `sheet` are already initialized +// (see the "Complete code" tab below for the full setup). // Initialize XlsIORenderer application.XlsIORenderer = new XlsIORenderer(); -// Converts and save as stream -MemoryStream stream = new MemoryStream(); -sheet.ConvertToImage(1, 1, 10, 20, stream); +// Convert and save as a stream (default image format on cross-platform is PNG). +using (MemoryStream stream = new MemoryStream()) +{ + sheet.ConvertToImage(1, 1, 10, 20, stream); +} {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} -// Converts and save as stream -MemoryStream stream = new MemoryStream(); -sheet.ConvertToImage(1, 1, 10, 20, ImageType.Metafile, stream); +// Convert and save as a stream with a specific ImageType +using (MemoryStream stream = new MemoryStream()) +{ + sheet.ConvertToImage(1, 1, 10, 20, ImageType.Metafile, stream); +} {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -'Converts and save as stream -Dim stream As MemoryStream = New MemoryStream() -sheet.ConvertToImage(1, 1, 10, 20, ImageType.Metafile, stream) +'Convert and save as a stream with a specific ImageType +Using stream As MemoryStream = New MemoryStream() + sheet.ConvertToImage(1, 1, 10, 20, ImageType.Metafile, stream) +End Using {% endhighlight %} {% endtabs %} @@ -80,22 +94,24 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); - IWorksheet sheet = workbook.Worksheets[0]; - - //Initialize XlsIORenderer - application.XlsIORenderer = new XlsIORenderer(); - - #region Save - //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Image.png"), FileMode.Create, FileAccess.Write); - sheet.ConvertToImage(sheet.UsedRange, outputStream); - #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); + + // Open the input workbook. + using (FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read)) + { + IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorksheet sheet = workbook.Worksheets[0]; + + //Initialize XlsIORenderer + application.XlsIORenderer = new XlsIORenderer(); + + #region Save + // Save the used range of the worksheet as a PNG image. + using (FileStream outputStream = new FileStream(Path.GetFullPath("Output/Image.png"), FileMode.Create, FileAccess.Write)) + { + sheet.ConvertToImage(sheet.UsedRange, outputStream); + } + #endregion + } } {% endhighlight %} @@ -107,20 +123,15 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic); IWorksheet sheet = workbook.Worksheets[0]; - //Convert as bitmap + // Convert the worksheet range to a bitmap image and save it as PNG. Image image = sheet.ConvertToImage(1, 1, 10, 20); - image.Save("Sample.png", ImageFormat.Png); - //Converts and save as stream - MemoryStream stream = new MemoryStream(); - sheet.ConvertToImage(1, 1, 10, 20, ImageType.Metafile, stream); - - //Save the workbook to disk - workbook.SaveAs("Sample.xlsx"); - - //No exception will be thrown if there are unsaved workbooks - excelEngine.ThrowNotSavedOnDestroy = false; + // Convert the worksheet range to a Metafile image and save it to a stream. + using (MemoryStream stream = new MemoryStream()) + { + sheet.ConvertToImage(1, 1, 10, 20, ImageType.Metafile, stream); + } } {% endhighlight %} @@ -128,28 +139,22 @@ using (ExcelEngine excelEngine = new ExcelEngine()) Using excelEngine As ExcelEngine = New ExcelEngine() Dim application As IApplication = excelEngine.Excel application.DefaultVersion = ExcelVersion.Xlsx - Dim workbook As IWorkbook = application.Workbooks.Open("sample.xlsx", ExcelOpenType.Automatic) - Dim worksheet As IWorksheet = workbook.Worksheets(0) - - 'Convert as bitmap - Dim image As Image = worksheet.ConvertToImage(1, 1, 10, 20) + Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic) + Dim sheet As IWorksheet = workbook.Worksheets(0) + ' Convert the worksheet range to a bitmap image and save it as PNG. + Dim image As Image = sheet.ConvertToImage(1, 1, 10, 20) image.Save("Sample.png", ImageFormat.Png) - 'Converts and save as stream - Dim stream As MemoryStream = New MemoryStream() - worksheet.ConvertToImage(1, 1, 10, 20, ImageType.Metafile, stream) - - 'Save the workbook to disk - workbook.SaveAs("Sample.xlsx") - - 'No exception will be thrown if there are unsaved workbooks. - excelEngine.ThrowNotSavedOnDestroy = False + ' Convert the worksheet range to a Metafile image and save it to a stream. + Using stream As MemoryStream = New MemoryStream() + sheet.ConvertToImage(1, 1, 10, 20, ImageType.Metafile, stream) + End Using End Using {% endhighlight %} -{% endtabs %} +{% endtabs %} -A complete working example to convert Excel worksheet to image in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Worksheet%20to%20Image/Worksheet%20to%20Image). +A complete working example to convert an Excel worksheet to an image in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Worksheet%20to%20Image/Worksheet%20to%20Image). N> 1. Instance of [XlsIORenderer](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.XlsIORenderer.XlsIORenderer.html) class is mandatory to convert the worksheet to image using .NET Standard assemblies. N> 2. In .NET Standard, the Image format and quality can be specified using the **ExportImageOptions** class. By default the [ImageFormat](https://help.syncfusion.com/cr/document-processing/Syncfusion.Drawing.ImageFormat.html) is set to PNG and [ScalingMode](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.ScalingMode.html) is set to Best. @@ -160,3 +165,9 @@ N> 3. Worksheet to image conversion is supported from .NET Framework 2.0 and .NE * Subscript/Superscript * Shrink to fit * Complex conditional formatting + +## See also + +* [Assemblies Information](https://help.syncfusion.com/document-processing/excel/excel-library/net/assemblies-required#converting-excel-worksheet-to-image) — manual assembly references. +* [NuGet Information](https://help.syncfusion.com/document-processing/excel/excel-library/net/nuget-packages-required#converting-excel-worksheet-to-image) — install the right package for your target platform. +* [Licensing overview](https://help.syncfusion.com/document-processing/licensing/overview) — register your license key. diff --git a/Document-Processing/Excel/Conversions/Excel-to-Image/overview.md b/Document-Processing/Excel/Conversions/Excel-to-Image/overview.md index 5017693f16..b2dcd216e2 100644 --- a/Document-Processing/Excel/Conversions/Excel-to-Image/overview.md +++ b/Document-Processing/Excel/Conversions/Excel-to-Image/overview.md @@ -6,43 +6,50 @@ control: XlsIO documentation: UG --- -# Worksheet to Image conversion in Excel Library +# Worksheet to Image Conversion in Excel Library -To quickly start converting an Excel document to a Image, please check out this video: -{% youtube "https://www.youtube.com/watch?v=WgugutAaxBk&t=3s" %} +To quickly start converting an Excel document to an image, see this short video: [Convert an Excel worksheet to an image with XlsIO](https://www.youtube.com/watch?v=WgugutAaxBk&t=3s). + +N> IMPORTANT: Before running the samples on this page, install the required NuGet package for your target platform and register your Syncfusion license key. For more information, see the [Licensing overview](https://help.syncfusion.com/document-processing/licensing/overview). ## Assemblies Required -Refer to the following links for assemblies/nuget packages required based on platforms to convert the worksheet to image. +The following links list the assemblies and NuGet packages required to convert a worksheet to an image, per platform: -* [Assemblies Information](https://help.syncfusion.com/file-formats/xlsio/assemblies-required#converting-excel-worksheet-to-image) +* [Assemblies Information](https://help.syncfusion.com/file-formats/xlsio/assemblies-required#converting-excel-worksheet-to-image) * [NuGet Information](https://help.syncfusion.com/file-formats/xlsio/nuget-packages-required#converting-excel-worksheet-to-image) -N> Worksheet To Image conversion can be performed by referring [Syncfusion.XlsIORenderer.Net.Core](https://www.nuget.org/packages/Syncfusion.XlsIORenderer.Net.Core) NuGet package in UWP platform. +N> Worksheet-to-image conversion can be performed by referring to the [Syncfusion.XlsIORenderer.Net.Core](https://www.nuget.org/packages/Syncfusion.XlsIORenderer.Net.Core) NuGet package in UWP platform. ## Convert as bitmap -The following code shows how to convert the specified range of rows and columns in the worksheet to bitmap. +The following code shows how to convert a specified range of rows and columns in the worksheet to a bitmap image. The four integer parameters are `firstRow`, `firstColumn`, `lastRow`, and `lastColumn` (1-based). {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} +// The following snippet assumes `application` and `worksheet` are already initialized +// (see the "Complete code" tab below for the full setup). // Initialize XlsIORenderer application.XlsIORenderer = new XlsIORenderer(); -//Create a new memory stream to save the image +// Create a new memory stream to save the image Stream stream = new MemoryStream(); -//Convert worksheet to image and save it to stream. +// Convert worksheet to image and save it to the stream. worksheet.ConvertToImage(1, 1, 10, 20, stream); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} +// The following snippet assumes `sheet` is already initialized (see the +// "Complete code" tab below for the full setup). // Convert as bitmap Image image = sheet.ConvertToImage(1, 1, 10, 20); image.Save("Sample.png", ImageFormat.Png); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +'The following snippet assumes `sheet` is already initialized (see the +'"Complete code" tab below for the full setup). 'Convert as bitmap Dim image As Image = sheet.ConvertToImage(1, 1, 10, 20) image.Save("Sample.png", ImageFormat.Png) @@ -51,28 +58,36 @@ image.Save("Sample.png", ImageFormat.Png) ## Save as stream -The following code snippet shows how to save a sheet as stream. +The following code snippet shows how to save a sheet as a stream. On Windows, you can choose the output [ImageType](https://help.syncfusion.com/cr/file-formats/Syncfusion.XlsIO.ImageType.html) (such as `Bitmap`, `Metafile`, or `EMF`); on .NET Standard the format is controlled by `ExportImageOptions`. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} +// The following snippet assumes `application` and `sheet` are already initialized +// (see the "Complete code" tab below for the full setup). // Initialize XlsIORenderer application.XlsIORenderer = new XlsIORenderer(); -// Converts and save as stream -MemoryStream stream = new MemoryStream(); -sheet.ConvertToImage(1, 1, 10, 20, stream); +// Convert and save as a stream +using (MemoryStream stream = new MemoryStream()) +{ + sheet.ConvertToImage(1, 1, 10, 20, stream); + // stream.Position = 0; // reset before reading, if needed +} {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} -// Converts and save as stream -MemoryStream stream = new MemoryStream(); -sheet.ConvertToImage(1, 1, 10, 20, ImageType.Metafile, stream); +// Convert and save as a stream with a specific ImageType +using (MemoryStream stream = new MemoryStream()) +{ + sheet.ConvertToImage(1, 1, 10, 20, ImageType.Metafile, stream); +} {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -'Converts and save as stream -Dim stream As MemoryStream = New MemoryStream() -sheet.ConvertToImage(1, 1, 10, 20, ImageType.Metafile, stream) +'Convert and save as a stream with a specific ImageType +Using stream As MemoryStream = New MemoryStream() + sheet.ConvertToImage(1, 1, 10, 20, ImageType.Metafile, stream) +End Using {% endhighlight %} {% endtabs %} @@ -84,22 +99,24 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); - IWorksheet sheet = workbook.Worksheets[0]; - - //Initialize XlsIORenderer - application.XlsIORenderer = new XlsIORenderer(); - - #region Save - //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Image.png"), FileMode.Create, FileAccess.Write); - sheet.ConvertToImage(sheet.UsedRange, outputStream); - #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); + + // Open the input workbook. + using (FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read)) + { + IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorksheet sheet = workbook.Worksheets[0]; + + //Initialize XlsIORenderer + application.XlsIORenderer = new XlsIORenderer(); + + #region Save + // Save the worksheet as a PNG image. + using (FileStream outputStream = new FileStream(Path.GetFullPath("Output/Image.png"), FileMode.Create, FileAccess.Write)) + { + sheet.ConvertToImage(sheet.UsedRange, outputStream); + } + #endregion + } } {% endhighlight %} @@ -111,20 +128,15 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic); IWorksheet sheet = workbook.Worksheets[0]; - //Convert as bitmap + // Convert the worksheet range to a bitmap image and save it as PNG. Image image = sheet.ConvertToImage(1, 1, 10, 20); - image.Save("Sample.png", ImageFormat.Png); - //Converts and save as stream - MemoryStream stream = new MemoryStream(); - sheet.ConvertToImage(1, 1, 10, 20, ImageType.Metafile, stream); - - //Save the workbook to disk - workbook.SaveAs("Sample.xlsx"); - - //No exception will be thrown if there are unsaved workbooks - excelEngine.ThrowNotSavedOnDestroy = false; + // Convert the worksheet range to a Metafile image and save it to a stream. + using (MemoryStream stream = new MemoryStream()) + { + sheet.ConvertToImage(1, 1, 10, 20, ImageType.Metafile, stream); + } } {% endhighlight %} @@ -132,23 +144,17 @@ using (ExcelEngine excelEngine = new ExcelEngine()) Using excelEngine As ExcelEngine = New ExcelEngine() Dim application As IApplication = excelEngine.Excel application.DefaultVersion = ExcelVersion.Xlsx - Dim workbook As IWorkbook = application.Workbooks.Open("sample.xlsx", ExcelOpenType.Automatic) - Dim worksheet As IWorksheet = workbook.Worksheets(0) - - 'Convert as bitmap - Dim image As Image = worksheet.ConvertToImage(1, 1, 10, 20) + Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic) + Dim sheet As IWorksheet = workbook.Worksheets(0) + ' Convert the worksheet range to a bitmap image and save it as PNG. + Dim image As Image = sheet.ConvertToImage(1, 1, 10, 20) image.Save("Sample.png", ImageFormat.Png) - 'Converts and save as stream - Dim stream As MemoryStream = New MemoryStream() - worksheet.ConvertToImage(1, 1, 10, 20, ImageType.Metafile, stream) - - 'Save the workbook to disk - workbook.SaveAs("Sample.xlsx") - - 'No exception will be thrown if there are unsaved workbooks. - excelEngine.ThrowNotSavedOnDestroy = False + ' Convert the worksheet range to a Metafile image and save it to a stream. + Using stream As MemoryStream = New MemoryStream() + sheet.ConvertToImage(1, 1, 10, 20, ImageType.Metafile, stream) + End Using End Using {% endhighlight %} {% endtabs %} @@ -164,3 +170,10 @@ N> 3. Worksheet to image conversion is supported from .NET Framework 2.0 and .NE * Subscript/Superscript * Shrink to fit * Complex conditional formatting + +## See also + +* [Worksheet to Image conversion in .NET](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-image/net/worksheet-to-image-conversion) — runnable code samples for each platform. +* [Assemblies Required for Excel to PDF conversion](../Excel-to-PDF/NET/assemblies-required-for-excel-to-pdf) — manual assembly references. +* [NuGet Packages Required for Excel to PDF conversion](../Excel-to-PDF/NET/nuget-packages-required-for-excel-to-pdf) — install the right package for your target platform. +* [Licensing overview](https://help.syncfusion.com/document-processing/licensing/overview) — register your license key. diff --git a/Document-Processing/Excel/Conversions/Excel-to-JSON/NET/Excel-to-JSON-Conversion.md b/Document-Processing/Excel/Conversions/Excel-to-JSON/NET/Excel-to-JSON-Conversion.md index 1d37f083df..80fffdd6c5 100644 --- a/Document-Processing/Excel/Conversions/Excel-to-JSON/NET/Excel-to-JSON-Conversion.md +++ b/Document-Processing/Excel/Conversions/Excel-to-JSON/NET/Excel-to-JSON-Conversion.md @@ -1,6 +1,6 @@ --- -title: Syncfusion Excel to JSON File Conversion -description: In this section, you can learn how to Export Excel workbook, worksheet, and custom range Data as JSON +title: Syncfusion Excel to JSON Conversion +description: Lists how to convert an Excel workbook, worksheet, or range to JSON using the Syncfusion .NET Excel (XlsIO) library. platform: document-processing control: XlsIO documentation: UG @@ -8,7 +8,7 @@ documentation: UG # Excel to JSON Conversion -Essential® XlsIO supports to convert Excel data as JSON files by simply saving the workbook using the [SaveAsJson](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IWorkbook.html#Syncfusion_XlsIO_IWorkbook_SaveAsJson_System_String_) method. This support includes the features: +XlsIO can convert an Excel workbook, worksheet, or range to JSON by calling [`IWorkbook.SaveAsJson`](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IWorkbook.html#Syncfusion_XlsIO_IWorkbook_SaveAsJson_System_String_). The output can be written to a file or a `Stream`, with or without a JSON schema. * Save as a simple JSON file or a JSON file as schema * Save a workbook to JSON @@ -121,7 +121,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} -using(ExcelEngine excelEngine = new ExcelEngine()) +using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; @@ -184,13 +184,11 @@ using (ExcelEngine excelEngine = new ExcelEngine()) {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} -using(ExcelEngine excelEngine = new ExcelEngine()) +using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic); - - //Active worksheet IWorksheet worksheet = workbook.Worksheets[0]; //Saves the worksheet to a JSON file, as schema by default @@ -210,12 +208,10 @@ using(ExcelEngine excelEngine = new ExcelEngine()) {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -Using excelEngine As ExcelEngine = New ExcelEngine() +Using excelEngine As New ExcelEngine() Dim application As IApplication = excelEngine.Excel application.DefaultVersion = ExcelVersion.Xlsx Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic) - - 'Active worksheet Dim worksheet As IWorksheet = workbook.Worksheets(0) 'Saves the worksheet to a JSON file, as schema by default @@ -339,8 +335,6 @@ using(ExcelEngine excelEngine = new ExcelEngine()) IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic); - - //Active worksheet IWorksheet worksheet = workbook.Worksheets[0]; //Custom range @@ -363,12 +357,10 @@ using(ExcelEngine excelEngine = new ExcelEngine()) {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -Using excelEngine As ExcelEngine = New ExcelEngine() +Using excelEngine As New ExcelEngine() Dim application As IApplication = excelEngine.Excel application.DefaultVersion = ExcelVersion.Xlsx Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic) - - 'Active worksheet Dim worksheet As IWorksheet = workbook.Worksheets(0) 'Custom range diff --git a/Document-Processing/Excel/Conversions/Excel-to-JSON/overview.md b/Document-Processing/Excel/Conversions/Excel-to-JSON/overview.md index 741826265d..f354f46eab 100644 --- a/Document-Processing/Excel/Conversions/Excel-to-JSON/overview.md +++ b/Document-Processing/Excel/Conversions/Excel-to-JSON/overview.md @@ -1,6 +1,6 @@ --- -title: Syncfusion Excel to JSON File Conversion | Syncfusion -description: This page explains how to export Excel workbook, worksheet, or custom range data into JSON format efficiently. +title: Syncfusion Excel to JSON Conversion +description: Lists how to convert an Excel workbook, worksheet, or range to JSON using the Syncfusion .NET Excel (XlsIO) library. platform: document-processing control: XlsIO documentation: UG @@ -104,68 +104,82 @@ The following code illustrates how to convert an Excel workbook to the JSON file {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/XlsIO-Examples/master/Convert%20Excel%20to%20JSON/Workbook%20to%20JSON%20without%20Schema/.NET/Workbook%20to%20JSON%20without%20Schema/Workbook%20to%20JSON%20without%20Schema/Program.cs,180" %} using (ExcelEngine excelEngine = new ExcelEngine()) { - IApplication application = excelEngine.Excel; - application.DefaultVersion = ExcelVersion.Xlsx; - IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); - IWorksheet worksheet = workbook.Worksheets[0]; + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"), ExcelOpenType.Automatic); - #region save as JSON - //Saves the workbook to JSON file without schema - workbook.SaveAsJson(Path.GetFullPath(@"Output/Workbook-To-JSON-without-schema.json"),false); - #endregion + // Save the workbook to JSON, as schema by default + workbook.SaveAsJson(Path.GetFullPath("Output/Workbook-To-JSON-with-schema.json")); - #region Open JSON - //Open default JSON - #endregion + // Save the workbook to JSON without schema + workbook.SaveAsJson(Path.GetFullPath("Output/Workbook-To-JSON-without-schema.json"), false); } {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} -using(ExcelEngine excelEngine = new ExcelEngine()) +using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic); - //Saves the workbook to a JSON file without schema + // Save the workbook to a JSON file, as schema by default + workbook.SaveAsJson("Excel-Workbook-To-JSON-with-schema.json"); + + // Save the workbook to a JSON file without schema workbook.SaveAsJson("Excel-Workbook-To-JSON-without-schema.json", false); - //Saves the workbook to a JSON filestream without schema - FileStream stream = new FileStream("Excel-Workbook-To-JSON-filestream-without-schema.json", FileMode.Create); - workbook.SaveAsJson(stream, false); + // Save the workbook to a JSON filestream, as schema by default + using (FileStream stream = new FileStream("Excel-Workbook-To-JSON-filestream-with-schema.json", FileMode.Create)) + { + workbook.SaveAsJson(stream); + } + + // Save the workbook to a JSON filestream without schema + using (FileStream stream = new FileStream("Excel-Workbook-To-JSON-filestream-without-schema.json", FileMode.Create)) + { + workbook.SaveAsJson(stream, false); + } } {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -Using excelEngine As ExcelEngine = New ExcelEngine() +Using excelEngine As New ExcelEngine() Dim application As IApplication = excelEngine.Excel application.DefaultVersion = ExcelVersion.Xlsx Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic) - 'Saves the workbook to a JSON file without schema - workbook.SaveAsJson("Excel-Workbook-To-JSON-without-schema.json", false) + ' Save the workbook to a JSON file, as schema by default + workbook.SaveAsJson("Excel-Workbook-To-JSON-with-schema.json") + + ' Save the workbook to a JSON file without schema + workbook.SaveAsJson("Excel-Workbook-To-JSON-without-schema.json", False) + + ' Save the workbook to a JSON filestream, as schema by default + Using stream As New FileStream("Excel-Workbook-To-JSON-filestream-with-schema.json", FileMode.Create) + workbook.SaveAsJson(stream) + End Using - 'Saves the workbook to a JSON filestream without schema - Dim stream As FileStream = new FileStream("Excel-Workbook-To-JSON-filestream-without-schema.json", FileMode.Create) - workbook.SaveAsJson(stream, false) + ' Save the workbook to a JSON filestream without schema + Using stream1 As New FileStream("Excel-Workbook-To-JSON-filestream-without-schema.json", FileMode.Create) + workbook.SaveAsJson(stream1, False) + End Using End Using {% endhighlight %} {% endtabs %} -A complete working example to convert Excel to JSON without schema in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Convert%20Excel%20to%20JSON/Workbook%20to%20JSON%20without%20Schema/.NET/Workbook%20to%20JSON%20without%20Schema). +## Worksheet to JSON -## Worksheet to JSON as schema - -The following code illustrates how to convert an Excel worksheet to the JSON file or JSON file stream with schema. +The following code converts the active worksheet to a JSON file or stream. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/XlsIO-Examples/master/Convert%20Excel%20to%20JSON/Worksheet%20to%20JSON%20with%20Schema/.NET/Worksheet%20to%20JSON%20with%20Schema/Worksheet%20to%20JSON%20with%20Schema/Program.cs,180" %} using (ExcelEngine excelEngine = new ExcelEngine()) { - IApplication application = excelEngine.Excel; - application.DefaultVersion = ExcelVersion.Xlsx; - IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); - IWorksheet worksheet = workbook.Worksheets[0]; + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"), ExcelOpenType.Automatic); + IWorksheet worksheet = workbook.Worksheets[0]; #region save as JSON //Saves the workbook to JSON, as schema by default @@ -184,13 +198,11 @@ using (ExcelEngine excelEngine = new ExcelEngine()) {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} -using(ExcelEngine excelEngine = new ExcelEngine()) +using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic); - - //Active worksheet IWorksheet worksheet = workbook.Worksheets[0]; //Saves the worksheet to a JSON file, as schema by default @@ -199,23 +211,25 @@ using(ExcelEngine excelEngine = new ExcelEngine()) //Saves the worksheet to a JSON file as schema workbook.SaveAsJson("Excel-Worksheet-To-JSON-as-schema.json", worksheet, true); - //Saves the worksheet to a JSON filestream, as schema by default - FileStream stream = new FileStream("Excel-Worksheet-To-JSON-filestream-as-schema-default.json", FileMode.Create); - workbook.SaveAsJson("stream", worksheet); - - //Saves the worksheet to a JSON filestream as schema - FileStream stream1 = new FileStream("Excel-Worksheet-To-JSON-filestream-as-schema.json", FileMode.Create); - workbook.SaveAsJson(stream1, worksheet, true); + // Save the worksheet to a JSON filestream, as schema by default + using (FileStream stream = new FileStream("Excel-Worksheet-To-JSON-filestream-with-schema.json", FileMode.Create)) + { + workbook.SaveAsJson(stream, worksheet); + } + + // Save the worksheet to a JSON filestream without schema + using (FileStream stream = new FileStream("Excel-Worksheet-To-JSON-filestream-without-schema.json", FileMode.Create)) + { + workbook.SaveAsJson(stream, worksheet, false); + } } {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -Using excelEngine As ExcelEngine = New ExcelEngine() +Using excelEngine As New ExcelEngine() Dim application As IApplication = excelEngine.Excel application.DefaultVersion = ExcelVersion.Xlsx Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic) - - 'Active worksheet Dim worksheet As IWorksheet = workbook.Worksheets(0) 'Saves the worksheet to a JSON file, as schema by default @@ -224,13 +238,15 @@ Using excelEngine As ExcelEngine = New ExcelEngine() 'Saves the worksheet to a JSON file as schema workbook.SaveAsJson("Excel-Worksheet-To-JSON-as-schema.json", worksheet, true) - 'Saves the worksheet to a JSON filestream as schema by default - Dim stream As FileStream = new FileStream("Excel-Worksheet-To-JSON-filestream-as-schema-default.json",FileMode.Create) - workbook.SaveAsJson(stream, worksheet) + ' Save the worksheet to a JSON filestream, as schema by default + Using stream As New FileStream("Excel-Worksheet-To-JSON-filestream-with-schema.json", FileMode.Create) + workbook.SaveAsJson(stream, worksheet) + End Using - 'Saves the worksheet to a JSON filestream as schema - Dim stream1 As FileStream = new FileStream("Excel-Worksheet-To-JSON-filestream-as-schema.json",FileMode.Create) - workbook.SaveAsJson(stream1, worksheet, true) + ' Save the worksheet to a JSON filestream without schema + Using stream1 As New FileStream("Excel-Worksheet-To-JSON-filestream-without-schema.json", FileMode.Create) + workbook.SaveAsJson(stream1, worksheet, False) + End Using End Using {% endhighlight %} {% endtabs %} @@ -363,7 +379,7 @@ using(ExcelEngine excelEngine = new ExcelEngine()) {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -Using excelEngine As ExcelEngine = New ExcelEngine() +Using excelEngine As New ExcelEngine() Dim application As IApplication = excelEngine.Excel application.DefaultVersion = ExcelVersion.Xlsx Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic) diff --git a/Document-Processing/Excel/Conversions/Excel-to-Markdown/NET/Excel-to-Markdown-Conversion.md b/Document-Processing/Excel/Conversions/Excel-to-Markdown/NET/Excel-to-Markdown-Conversion.md index c8a1a47559..28340789a2 100644 --- a/Document-Processing/Excel/Conversions/Excel-to-Markdown/NET/Excel-to-Markdown-Conversion.md +++ b/Document-Processing/Excel/Conversions/Excel-to-Markdown/NET/Excel-to-Markdown-Conversion.md @@ -1,6 +1,6 @@ --- title: Convert Excel to Markdown in C# | XlsIO | Syncfusion -description: Convert Excel to Markdown in C# using Syncfusion® .NET Excel (XlsIO) library without Microsoft Excel or interop dependencies +description: Lists how to convert an Excel workbook or worksheet to a Markdown file using the Syncfusion .NET Excel (XlsIO) library, with no Microsoft Office or interop dependencies. platform: document-processing control: XlsIO documentation: UG @@ -12,7 +12,7 @@ Markdown is a lightweight markup language that adds formatting elements to plain ## Assemblies and NuGet packages required -Refer to the following links for assemblies and NuGet packages required based on platforms to convert an Excel document to Markdown using the .NET Excel Library (XlsIO). +For the assemblies and NuGet packages required to convert Excel to Markdown, see the per-platform lists below. * [Excel to Markdown conversion assemblies](https://help.syncfusion.com/document-processing/excel/excel-library/net/assemblies-required) * [Excel to Markdown conversion NuGet packages](https://help.syncfusion.com/document-processing/excel/excel-library/net/nuget-packages-required) @@ -164,7 +164,7 @@ Private Sub MdExportSettings_ImageNodeVisited(sender As Object, args As SaveImag Using fileStreamOutput As FileStream = File.Create(imagePath) args.ImageStream.CopyTo(fileStreamOutput) End Using - ' Set the image URI to be used in the output markdown + ' Set the image URI to be used in the output Markdown. args.Uri = imagePath End Sub {% endhighlight %} diff --git a/Document-Processing/Excel/Conversions/Excel-to-Markdown/overview.md b/Document-Processing/Excel/Conversions/Excel-to-Markdown/overview.md index 71b6746c9e..334f64303b 100644 --- a/Document-Processing/Excel/Conversions/Excel-to-Markdown/overview.md +++ b/Document-Processing/Excel/Conversions/Excel-to-Markdown/overview.md @@ -1,6 +1,6 @@ --- title: Convert Excel to Markdown in C# | XlsIO | Syncfusion -description: Convert Excel to Markdown in C# using Syncfusion® .NET Excel (XlsIO) library without Microsoft Excel or interop dependencies +description: Lists how to convert an Excel workbook or worksheet to a Markdown file using the Syncfusion .NET Excel (XlsIO) library, with no Microsoft Office or interop dependencies. platform: document-processing control: XlsIO documentation: UG @@ -12,12 +12,12 @@ Markdown is a lightweight markup language that adds formatting elements to plain ## Assemblies and NuGet packages required -Refer to the following links for assemblies and NuGet packages required based on platforms to convert an Excel document to Markdown using the .NET Excel Library (XlsIO). +For the assemblies and NuGet packages required to convert Excel to Markdown, see the per-platform lists below. * [Excel to Markdown conversion assemblies](https://help.syncfusion.com/document-processing/excel/excel-library/net/assemblies-required) * [Excel to Markdown conversion NuGet packages](https://help.syncfusion.com/document-processing/excel/excel-library/net/nuget-packages-required) -## Convert Excel to Markdown document +## Convert Excel to Markdown Convert an existing Excel file to Markdown using the .NET Excel (XlsIO) library. @@ -164,7 +164,7 @@ Private Sub MdExportSettings_ImageNodeVisited(sender As Object, args As SaveImag Using fileStreamOutput As FileStream = File.Create(imagePath) args.ImageStream.CopyTo(fileStreamOutput) End Using - ' Set the image URI to be used in the output markdown + ' Set the image URI to be used in the output Markdown. args.Uri = imagePath End Sub {% endhighlight %} diff --git a/Document-Processing/Excel/Conversions/Excel-to-ODS/NET/Excel-to-ODS-Conversion.md b/Document-Processing/Excel/Conversions/Excel-to-ODS/NET/Excel-to-ODS-Conversion.md index 458206ef72..f8330cff4a 100644 --- a/Document-Processing/Excel/Conversions/Excel-to-ODS/NET/Excel-to-ODS-Conversion.md +++ b/Document-Processing/Excel/Conversions/Excel-to-ODS/NET/Excel-to-ODS-Conversion.md @@ -1,6 +1,6 @@ --- title: Excel to ODS Conversion in .NET Excel Library | Syncfusion -description: In this section, you can learn how to convert Excel docuemnts to ODS docuemnts using .NET Excel Library +description: Lists how to convert an Excel workbook to an ODS document using the Syncfusion .NET Excel (XlsIO) library. platform: document-processing control: XlsIO documentation: UG @@ -8,11 +8,15 @@ documentation: UG # Excel to ODS Conversion -The Open Document Format for Office Applications (ODF) is also known as OpenDocument. It is an XML-based file format for spreadsheets, charts, presentations, and word processing documents. It was developed with the aim of providing an open and XML-based file format specification for office applications. OpenOffice uses ODF format as its default document format. The OpenDocument Spreadsheet (ODS) is the file format for Excel documents. XlsIO supports conversion of XLS/XLSX documents to ODS. +The OpenDocument Format (ODF) is an XML-based file format for spreadsheets, charts, presentations, and word-processing documents. The OpenDocument Spreadsheet (ODS) format is the spreadsheet counterpart used by OpenOffice and LibreOffice. XlsIO converts XLS and XLSX workbooks to ODS. -## Saving ODS in different platforms +To write an ODS file, set `application.DefaultVersion` to a value that maps to ODS (`ExcelVersion.Excel2013` is shown in the samples below; older values such as `Excel2010` are also accepted) and call `workbook.SaveAs("Output.ods")`. All sheets in the workbook are exported. -The following code snippet illustrates the creation of an Excel file and exporting it to ODS format. +N> IMPORTANT: Before running the samples on this page, install the required NuGet package for your target platform and register your Syncfusion license key. For more information, see the [Licensing overview](https://help.syncfusion.com/document-processing/licensing/overview). + +## Export to ODS + +The following code snippet creates an Excel file and exports it to ODS format. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/XlsIO-Examples/master/Excel%20to%20ODS/Excel%20to%20ODS/.NET/Excel%20to%20ODS/Excel%20to%20ODS/Program.cs,180" %} @@ -35,7 +39,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) worksheet.Range["B3"].Number = 71550; worksheet.Range["B5"].Formula = "SUM(B2:B4)"; - //Comments + // Comments IComment comment = worksheet.Range["B5"].AddComment(); comment.RichText.Text = "This cell has formula."; @@ -49,7 +53,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) redFont.Color = ExcelKnownColors.Red; richText.SetFont(14, 20, redFont); - //Formatting + // Formatting IStyle style = workbook.Styles.Add("Style1"); style.Color = Syncfusion.Drawing.Color.DarkBlue; style.Font.Color = ExcelKnownColors.WhiteCustom; @@ -57,10 +61,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) worksheet.Range["A1:B1"].CellStyleName = "Style1"; worksheet.Range["A5:B5"].CellStyleName = "Style1"; - #region Save - //Saving the workbook + // Save the workbook as ODS workbook.SaveAs("Output.ods"); - #endregion } {% endhighlight %} @@ -84,7 +86,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) worksheet.Range["B3"].Number = 71550; worksheet.Range["B5"].Formula = "SUM(B2:B4)"; - //Comments + // Comments IComment comment = worksheet.Range["B5"].AddComment(); comment.RichText.Text = "This cell has formula."; @@ -98,7 +100,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) redFont.Color = ExcelKnownColors.Red; richText.SetFont(14, 20, redFont); - //Formatting + // Formatting IStyle style = workbook.Styles.Add("Style1"); style.Color = Color.DarkBlue; style.Font.Color = ExcelKnownColors.WhiteCustom; @@ -106,13 +108,13 @@ using (ExcelEngine excelEngine = new ExcelEngine()) worksheet.Range["A1:B1"].CellStyleName = "Style1"; worksheet.Range["A5:B5"].CellStyleName = "Style1"; - //Save in ODS format + // Save the workbook as ODS workbook.SaveAs("Output.ods"); } {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -Using excelEngine As ExcelEngine = New ExcelEngine() +Using excelEngine As New ExcelEngine() Dim application As IApplication = excelEngine.Excel application.DefaultVersion = ExcelVersion.Excel2013 Dim workbook As IWorkbook = application.Workbooks.Create(1) @@ -130,7 +132,7 @@ Using excelEngine As ExcelEngine = New ExcelEngine() worksheet.Range("B3").Number = 71550 worksheet.Range("B5").Formula = "SUM(B2:B4)" - 'Comments + ' Comments Dim comment As IComment = worksheet.Range("B5").AddComment() comment.RichText.Text = "This cell has formula." @@ -144,7 +146,7 @@ Using excelEngine As ExcelEngine = New ExcelEngine() redFont.Color = ExcelKnownColors.Red richText.SetFont(14, 20, redFont) - 'Formatting + ' Formatting Dim style As IStyle = workbook.Styles.Add("Style1") style.Color = Color.DarkBlue style.Font.Color = ExcelKnownColors.WhiteCustom @@ -152,396 +154,61 @@ Using excelEngine As ExcelEngine = New ExcelEngine() worksheet.Range("A1:B1").CellStyleName = "Style1" worksheet.Range("A5:B5").CellStyleName = "Style1" - 'Save in ODS format + ' Save the workbook as ODS workbook.SaveAs("Output.ods") End Using {% endhighlight %} {% endtabs %} -A complete working example to convert Excel to ODS in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Excel%20to%20ODS/Excel%20to%20ODS/.NET/Excel%20to%20ODS). +A complete working example to convert Excel to ODS in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Excel%20to%20ODS/Excel%20to%20ODS/.NET/Excel%20to%20ODS). ## Supported and unsupported elements in ODS conversion -
| -{{'**Category**'| markdownify }} - | --{{'**Subcategory**'| markdownify }} - | --{{'**Supported**'| markdownify }} - | -
| -Formatting - | -
-Font settings |
--Yes - | -
| - - | --Alignments - | --Yes (Except indent) - | -
| - - | --Number formatting - | --Yes (Partial) - | -
| - - | -
-Border settings |
--Yes - | -
| - - | -
-Fill settings |
--Yes - | -
| - - | --RGB colors - | --Yes - | -
| - - | -
-Cell gradient |
--No - | -
| - - | -
-Cell styles |
--Yes - | -
| - - | --Themes - | --No - | -
| - - | -
-Conditional formatting |
--Planned - | -
| -Hyperlinks - | --- - | -- Yes - | -
| -Cell Comments - | --- - | --Yes - | -
| -Print - | -
-Page setup |
--Yes - | -
| - - | -
-[Margin, Page size] |
--Yes - | -
| - - | -
-Page breaks |
--No - | -
| - - | -
-Background image |
--No - | -
| - - | -
-Print settings [Print area, Print titles, Page order] |
--No - | -
| - - | -
-Header/Footer |
--Planned - | -
| -Calculations - | --Formulas - | --Yes (Partial) - | -
| - - | --Table Formulas - | --No - | -
| - - | --Names - | --Yes (Partial) - | -
| -Group & Outline - | --- - | --Yes - | -
| -Settings - | --Window Settings - | --No - | -
| - - | --Sheet/Book settings - | --No - | -
| -Protection - | --Sheet Protection - | --No - | -
| - - | --Encryption - | --N/A - | -
|
-Hide/Unhide rows/cols |
--- - | --Yes - | -
|
-Copy/Move worksheet |
--- - | --Yes - | -
|
-Image |
--- - | --No - | -
| -Data Validation - | --- - | --No - | -
| -Tables - | --- - | --Planned - | -
| -PivotTable - | --- - | --No - | -
| -Charts - | --- - | --Planned - | -
| -Drawing - | --- - | --Planned - | -
| -OLE Objects - | --- - | --No - | -
| -{{'**Category**'| markdownify }} - | --{{'**Subcategory**'| markdownify }} - | --{{'**Supported**'| markdownify }} - | -
| -Formatting - | -
-Font settings |
--Yes - | -
| - - | --Alignments - | --Yes (Except indent) - | -
| - - | --Number formatting - | --Yes (Partial) - | -
| - - | -
-Border settings |
--Yes - | -
| - - | -
-Fill settings |
--Yes - | -
| - - | --RGB colors - | --Yes - | -
| - - | -
-Cell gradient |
--No - | -
| - - | -
-Cell styles |
--Yes - | -
| - - | --Themes - | --No - | -
| - - | -
-Conditional formatting |
--Planned - | -
| -Hyperlinks - | --- - | -- Yes - | -
| -Cell Comments - | --- - | --Yes - | -
| -Print - | -
-Page setup |
--Yes - | -
| - - | -
-[Margin, Page size] |
--Yes - | -
| - - | -
-Page breaks |
--No - | -
| - - | -
-Background image |
--No - | -
| - - | -
-Print settings [Print area, Print titles, Page order] |
--No - | -
| - - | -
-Header/Footer |
--Planned - | -
| -Calculations - | --Formulas - | --Yes (Partial) - | -
| - - | --Table Formulas - | --No - | -
| - - | --Names - | --Yes (Partial) - | -
| -Group & Outline - | --- - | --Yes - | -
| -Settings - | --Window Settings - | --No - | -
| - - | --Sheet/Book settings - | --No - | -
| -Protection - | --Sheet Protection - | --No - | -
| - - | --Encryption - | --N/A - | -
|
-Hide/Unhide rows/cols |
--- - | --Yes - | -
|
-Copy/Move worksheet |
--- - | --Yes - | -
|
-Image |
--- - | --No - | -
| -Data Validation - | --- - | --No - | -
| -Tables - | --- - | --Planned - | -
| -PivotTable - | --- - | --No - | -
| -Charts - | --- - | --Planned - | -
| -Drawing - | --- - | --Planned - | -
| -OLE Objects - | --- - | --No - | -
| Platform(s) @@ -19,6 +20,7 @@ Platform(s) Assembly |
|---|
| @@ -32,7 +34,6 @@ Syncfusion.ExcelToPDFConverter.Base |
| {{'[ASP.NET Core](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-pdf/net/convert-excel-to-pdf-in-asp-net-core)' | markdownify}}, {{'[Xamarin](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-pdf/net/convert-excel-to-pdf-in-xamarin)' | markdownify}} and {{'[Blazor](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-pdf/net/convert-excel-to-pdf-in-blazor)' | markdownify}} | @@ -76,6 +77,7 @@ Assembly
|
{{'[ASP.NET](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-pdf/net/convert-excel-to-pdf-in-asp-net)' | markdownify}} @@ -84,14 +86,13 @@ Assembly Syncfusion.XlsIO.Base Syncfusion.Compression.Base Syncfusion.Pdf.Base -Syncfusion.ExcelToPdfConverter.Base +Syncfusion.ExcelToPDFConverter.Base |
| Data type | -Time Taken (sec) | -Sample Link | -
|---|---|---|
| Text | -91 | -GitHub page | -
| DateTime | -105 | -GitHub page | -
| Number | -96 | -GitHub page | -
| Boolean | -81 | -GitHub page | -
| Formula | -104 | -GitHub page | -