<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Excel - TheCodeBuzz</title>
	<atom:link href="https://thecodebuzz.com/category/excel/feed/" rel="self" type="application/rss+xml" />
	<link>https://thecodebuzz.com</link>
	<description>Best Practices for Software Development</description>
	<lastBuildDate>Sun, 10 Mar 2024 03:38:08 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://thecodebuzz.com/wp-content/uploads/2022/11/cropped-android-chrome-512x512-1-1-51x51.jpg</url>
	<title>Excel - TheCodeBuzz</title>
	<link>https://thecodebuzz.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>EPPlus &#8211; How to Read/Write Excel files in C# .NET Core</title>
		<link>https://thecodebuzz.com/read-write-excel-in-dotnet-core-epplus/</link>
					<comments>https://thecodebuzz.com/read-write-excel-in-dotnet-core-epplus/#comments</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Thu, 08 Sep 2022 01:59:00 +0000</pubDate>
				<category><![CDATA[.NET Core]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[.net core create excel file]]></category>
		<category><![CDATA[.net core epplus]]></category>
		<category><![CDATA[.net core excel]]></category>
		<category><![CDATA[.net core excel library]]></category>
		<category><![CDATA[.net core read excel file]]></category>
		<category><![CDATA[asp.net core epplus]]></category>
		<category><![CDATA[asp.net core epplus epplus write excel]]></category>
		<category><![CDATA[c# epplus read excel file]]></category>
		<category><![CDATA[C# read excel]]></category>
		<category><![CDATA[creat xlsx .net core]]></category>
		<category><![CDATA[create Excel .net core]]></category>
		<category><![CDATA[create excel without msoffice]]></category>
		<category><![CDATA[create xlsx]]></category>
		<category><![CDATA[documentformat.openxml .net core]]></category>
		<category><![CDATA[dotnet core excel]]></category>
		<category><![CDATA[dotnet core read excel file]]></category>
		<category><![CDATA[dotnet excel]]></category>
		<category><![CDATA[epplus]]></category>
		<category><![CDATA[epplus .net]]></category>
		<category><![CDATA[epplus .net core]]></category>
		<category><![CDATA[epplus .net core 6.0]]></category>
		<category><![CDATA[epplus .net core example]]></category>
		<category><![CDATA[epplus asp.net]]></category>
		<category><![CDATA[epplus asp.net core]]></category>
		<category><![CDATA[epplus c#]]></category>
		<category><![CDATA[epplus c# read excel]]></category>
		<category><![CDATA[epplus c# read excel file]]></category>
		<category><![CDATA[epplus create excel file]]></category>
		<category><![CDATA[epplus dotnet core]]></category>
		<category><![CDATA[epplus examples]]></category>
		<category><![CDATA[epplus export excel]]></category>
		<category><![CDATA[epplus export to excel]]></category>
		<category><![CDATA[epplus export to excel asp.net core]]></category>
		<category><![CDATA[epplus for .net core]]></category>
		<category><![CDATA[epplus import excel]]></category>
		<category><![CDATA[epplus load excel file]]></category>
		<category><![CDATA[epplus nuget]]></category>
		<category><![CDATA[epplus open excel file]]></category>
		<category><![CDATA[epplus read csv]]></category>
		<category><![CDATA[epplus read excel]]></category>
		<category><![CDATA[epplus read excel c#]]></category>
		<category><![CDATA[epplus read excel file]]></category>
		<category><![CDATA[epplus read excel from stream]]></category>
		<category><![CDATA[epplus read excel rows]]></category>
		<category><![CDATA[epplus read xls]]></category>
		<category><![CDATA[epplus vs npoi]]></category>
		<category><![CDATA[epplus write excel]]></category>
		<category><![CDATA[epplus.core]]></category>
		<category><![CDATA[Eppplus]]></category>
		<category><![CDATA[Excel in .NET Core 5.0]]></category>
		<category><![CDATA[Excel in .NET Core 6.0]]></category>
		<category><![CDATA[excel to datatable .net core]]></category>
		<category><![CDATA[export datatable to excel]]></category>
		<category><![CDATA[export xlsx]]></category>
		<category><![CDATA[export xlsx .net core]]></category>
		<category><![CDATA[Import and Export excel in .NET Core]]></category>
		<category><![CDATA[import data from excel using epplus]]></category>
		<category><![CDATA[import xlsx]]></category>
		<category><![CDATA[net core 3.1 read excel file]]></category>
		<category><![CDATA[open xml sdk .net core]]></category>
		<category><![CDATA[openxml .net core]]></category>
		<category><![CDATA[OpenXML SDK]]></category>
		<category><![CDATA[Read csv]]></category>
		<category><![CDATA[Read Data from excel in .NET]]></category>
		<category><![CDATA[Read excel]]></category>
		<category><![CDATA[read excel .net core]]></category>
		<category><![CDATA[read excel epplus c#]]></category>
		<category><![CDATA[read excel file]]></category>
		<category><![CDATA[read excel file in c# using epplus]]></category>
		<category><![CDATA[read excel using epplus c#]]></category>
		<category><![CDATA[read excel using epplus c# epplus export to excel]]></category>
		<category><![CDATA[read xlsx]]></category>
		<category><![CDATA[read xlsx .NET]]></category>
		<category><![CDATA[Read/Write Excel file in .NET core 5.0]]></category>
		<category><![CDATA[write xlsx]]></category>
		<guid isPermaLink="false">https://thecodebuzz.com/?p=2591</guid>

					<description><![CDATA[<p>EPPlus &#8211; Read/Write Excel files in C# .NET Core Today in this article we will see the simple approach of How to Read/Write Excel files in .NET Core using EPPlus. In our last post, we saw the usage of OpenXML SDK (open source SDK from Microsoft) to work with Office Word, Excel, and PowerPoint using [&#8230;]</p>
<p>The post <a href="https://thecodebuzz.com/read-write-excel-in-dotnet-core-epplus/">EPPlus – How to Read/Write Excel files in C# .NET Core</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></description>
										<content:encoded><![CDATA[<h1 class="wp-block-heading">EPPlus &#8211; Read/Write Excel files in C# .NET Core</h1>



<figure class="wp-block-image"><img fetchpriority="high" decoding="async" width="1980" height="623" src="https://i2.wp.com/thecodebuzz.com/wp-content/uploads/2019/04/Read-write-excel-in-dotnet-core-2.1-epplus.jpg?fit=785%2C247&amp;ssl=1" alt="EPPlus - Read/Write Excel files in .NET Core using C# " class="wp-image-2614" srcset="https://thecodebuzz.com/wp-content/uploads/2019/04/Read-write-excel-in-dotnet-core-2.1-epplus.jpg 1980w, https://thecodebuzz.com/wp-content/uploads/2019/04/Read-write-excel-in-dotnet-core-2.1-epplus-300x94.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/04/Read-write-excel-in-dotnet-core-2.1-epplus-1024x322.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/04/Read-write-excel-in-dotnet-core-2.1-epplus-768x242.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/04/Read-write-excel-in-dotnet-core-2.1-epplus-1536x483.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/04/Read-write-excel-in-dotnet-core-2.1-epplus-785x247.jpg 785w" sizes="(max-width: 1980px) 100vw, 1980px" /></figure>



<p>Today in this article we will see the simple approach of How to Read/Write Excel files in .NET Core using EPPlus.</p>



<p></p>



<p>In our last post, we saw the usage of <strong>OpenXML </strong>SDK (open source SDK from Microsoft) to work with Office Word, Excel, and PowerPoint using the C# language. </p>



<p></p>



<p></p>



<p>Today, in this article we shall cover the below using <a href="https://www.thecodebuzz.com/read-write-excel-in-dotnet-core-epplus/" target="_blank" rel="noopener" title="Read/Write Excel file in .NET Core using EPPlus"><strong><em>EPPLus</em></strong></a>,</p>



<p></p>



<div class="wp-block-aioseo-table-of-contents"><ul><li><a href="#aioseo-what-is-epplus">What is EPPLus</a></li><li><a href="#aioseo-you-dont-need-microsoft-office">You don&#x27;t need Microsoft Office</a></li><li><a href="#aioseo-getting-started">Getting Started</a></li><li><a href="#aioseo-read-the-content-of-excel-file-using-epplus">Read the content of the Excel file using EPPlus</a></li><li><a href="#aioseo-json-to-generic-type-conversion-dynamically">JSON to Generic Type Conversion Dynamically</a></li><li><a href="#aioseo-read-excel-as-json-output">Read Excel as JSON output</a></li><li><a href="#aioseo-client-side-code">Client-side Code</a><ul><li><a href="#aioseo-export-write-the-data-to-excel-file-using-epplus-api">Export/Write the data to an Excel file using EPPlus API</a></li></ul></li><li><a href="#aioseo-summary">Summary</a></li></ul></div>



<p></p>



<p>Please see below for your reference,</p>



<p></p>



<ul class="wp-block-list">
<li><a href="https://www.thecodebuzz.com/read-excel-file-in-dotnet-core-2-1/" target="_blank" rel="noreferrer noopener"><em><strong>Read/Write excel file .NET Core using OpemXML SDK</strong></em></a></li>
</ul>



<p></p>



<div data-schema-only="false" class="wp-block-aioseo-faq" id="aioseo-what-is-epplus"><h3 class="aioseo-faq-block-question">What is EPPLus</h3><div class="aioseo-faq-block-answer">
<p><strong>EPPlus </strong>is a .NET open-source library for easily managing Microsoft Excel files in .xlsx format. With EPPlus, developers can <strong><em>create, read, write, and modify Excel</em></strong> <strong><em>spreadsheets </em></strong>programmatically without the need for Microsoft Office to be installed on the system. </p>



<p></p>
</div></div>



<p><strong><em>EPPLus </em></strong>provides API for working with Office Excel documents. </p>



<p>EPPlus is efficient and performs well, making it an excellent choice for applications that require Excel integration, reporting, data analysis, or data export functionalities.</p>



<p></p>



<p>This library provides a rich set of APIs to work with cells, rows, columns, formulas, formatting, charts, and more, making it suitable for a wide range of Excel-related tasks. </p>



<p></p>



<p></p>



<p></p>



<p>This library can be installed from NuGet as a package. </p>



<p></p>



<h2 class="wp-block-heading" id="aioseo-you-dont-need-microsoft-office">You don&#8217;t need Microsoft Office</h2>



<p></p>



<p>Please note that Reading and Creating Excel in C# is possible <strong>without installing Microsoft Office</strong>. </p>



<p></p>



<p>Today we will see a few possible and easy-to-implement approaches.</p>



<p></p>



<h2 class="wp-block-heading" id="aioseo-getting-started"><strong>Getting Started</strong></h2>



<p></p>



<p>Let&#8217;s create a .NET Core project, you can choose any project template. </p>



<p></p>



<p><strong><em>EPPlus </em></strong>API works perfectly fine for any .NET Core Project template. </p>



<p></p>



<p>Here to keep it simple I am using a Console .NET Core application.</p>



<p></p>



<figure class="wp-block-image"><img decoding="async" width="1572" height="565" src="https://i1.wp.com/thecodebuzz.com/wp-content/uploads/2019/01/image-5.png?fit=785%2C282&amp;ssl=1" alt="EPPlus - Read/Write Excel file in .NET Core using" class="wp-image-1543" srcset="https://thecodebuzz.com/wp-content/uploads/2019/01/image-5.png 1572w, https://thecodebuzz.com/wp-content/uploads/2019/01/image-5-300x108.png 300w, https://thecodebuzz.com/wp-content/uploads/2019/01/image-5-1024x368.png 1024w, https://thecodebuzz.com/wp-content/uploads/2019/01/image-5-768x276.png 768w, https://thecodebuzz.com/wp-content/uploads/2019/01/image-5-1536x552.png 1536w, https://thecodebuzz.com/wp-content/uploads/2019/01/image-5-785x282.png 785w" sizes="(max-width: 1572px) 100vw, 1572px" /></figure>



<p></p>



<p> The NuGet Package name is <strong>EPPlus.</strong></p>



<p></p>



<pre class="wp-block-preformatted has-medium-font-size">PM&gt; Install-Package <a href="https://www.nuget.org/packages/EPPlus/" target="_blank" rel="noopener" title="">EPPlus </a></pre>



<p></p>



<p>[<strong>Note</strong>: Please use the latest available version]</p>



<p></p>



<p>Let&#8217;s look at a simple example, I have a simple Excel file with below columns and rows details. We shall first read this file programmatically.</p>



<p></p>



<p>Please make sure to add below using statements as needed,</p>



<p></p>



<pre class="wp-block-verse"><em>using OfficeOpenXml;</em></pre>



<p></p>



<figure class="wp-block-image"><img decoding="async" width="1078" height="924" src="https://i2.wp.com/thecodebuzz.com/wp-content/uploads/2019/01/Read-excel-in-dotnet-core-2.1.jpg?fit=785%2C673&amp;ssl=1" alt="epplus read excel,
epplus read excel to datatable,
epplus free,
epplus read row,
epplus read excel from stream c#,
epplus list to excel,
epplus xls,
epplus license,
epplus documentation pdf," class="wp-image-1502" srcset="https://thecodebuzz.com/wp-content/uploads/2019/01/Read-excel-in-dotnet-core-2.1.jpg 1078w, https://thecodebuzz.com/wp-content/uploads/2019/01/Read-excel-in-dotnet-core-2.1-300x257.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/01/Read-excel-in-dotnet-core-2.1-1024x878.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/01/Read-excel-in-dotnet-core-2.1-768x658.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/01/Read-excel-in-dotnet-core-2.1-607x520.jpg 607w" sizes="(max-width: 1078px) 100vw, 1078px" /></figure>



<p></p>



<h2 class="wp-block-heading" id="aioseo-read-the-content-of-excel-file-using-epplus"><strong>Read the content of the Excel file using EPPlus </strong></h2>



<p></p>



<p>Please use the below &#8216;Ready to Use&#8217; Method in your application. </p>



<p></p>



<p>This method returns the result as a type so that you can read the excel result in the type of your choice.</p>



<p></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
private static T ReadFromExcel&lt;T&gt;(string path, bool hasHeader = true)
        {
            using (var excelPack = new ExcelPackage())
            {
                //Load excel stream
                using (var stream = File.OpenRead(path))
                {
                    excelPack.Load(stream);
                }

                //Lets Deal with first worksheet.(You may iterate here if dealing with multiple sheets)
                var ws = excelPack.Workbook.Worksheets&#x5B;0];

                //Get all details as DataTable -because Datatable make life easy :)
                DataTable excelasTable = new DataTable();
                foreach (var firstRowCell in ws.Cells&#x5B;1, 1, 1, ws.Dimension.End.Column])
                {
                    //Get colummn details
                    if (!string.IsNullOrEmpty(firstRowCell.Text))
                    {
                        string firstColumn = string.Format(&quot;Column {0}&quot;, firstRowCell.Start.Column);
                        excelasTable.Columns.Add(hasHeader ? firstRowCell.Text : firstColumn);
                    }
                }
                var startRow = hasHeader ? 2 : 1;
                //Get row details
                for (int rowNum = startRow; rowNum &lt;= ws.Dimension.End.Row; rowNum++)
                {
                    var wsRow = ws.Cells&#x5B;rowNum, 1, rowNum, excelasTable.Columns.Count];
                    DataRow row = excelasTable.Rows.Add();
                    foreach (var cell in wsRow)
                    {
                        row&#x5B;cell.Start.Column - 1] = cell.Text;
                    }
                }
               //Get everything as generics and let end user decides on casting to required type
                var generatedType = JsonConvert.DeserializeObject&lt;T&gt;(JsonConvert.SerializeObject(excelasTable));
                return (T)Convert.ChangeType(generatedType, typeof(T));
            }
        }
</pre></div>


<br>



<p></p>



<h2 class="wp-block-heading" id="aioseo-json-to-generic-type-conversion-dynamically">JSON to Generic Type Conversion Dynamically </h2>



<p></p>



<p>Please refer to this article &#8211; <a href="https://www.thecodebuzz.com/deserialize-json-into-type-object-dynamically" target="_blank" rel="noreferrer noopener"><strong><em>logic will generate type dynamically which can be cast to the </em></strong></a>appropriate type as needed. </p>



<p></p>



<br>



<h2 class="wp-block-heading" id="aioseo-read-excel-as-json-output">Read Excel as JSON output</h2>



<p></p>



<p>Excel as JSON will be generated using the below one-liner code.</p>



<p></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; first-line: 0; title: ; notranslate">
string strJSON = JsonConvert.SerializeObject(excelasTable)
</pre></div>


<p></p>



<p>After executing the above API, The results will be printed on the console as below.</p>



<p></p>



<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" width="1836" height="342" src="https://i1.wp.com/thecodebuzz.com/wp-content/uploads/2019/04/Read-excel-in-dotnet-core-2.1-epplus.jpg?fit=785%2C146&amp;ssl=1" alt="" class="wp-image-2599" style="width:607px;height:113px" srcset="https://thecodebuzz.com/wp-content/uploads/2019/04/Read-excel-in-dotnet-core-2.1-epplus.jpg 1836w, https://thecodebuzz.com/wp-content/uploads/2019/04/Read-excel-in-dotnet-core-2.1-epplus-300x56.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/04/Read-excel-in-dotnet-core-2.1-epplus-1024x191.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/04/Read-excel-in-dotnet-core-2.1-epplus-768x143.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/04/Read-excel-in-dotnet-core-2.1-epplus-1536x286.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/04/Read-excel-in-dotnet-core-2.1-epplus-785x146.jpg 785w" sizes="auto, (max-width: 1836px) 100vw, 1836px" /></figure>



<p></p>



<p>Here I have used the simple accessor class <em><strong>UserDetails</strong>.  </em></p>



<p></p>



<p>This class will help in serializing and deserializing the Excel data.</p>



<p></p>



<pre class="wp-block-preformatted">public class UserDetails
    {
        public string ID { get; set; }
        public string Name { get; set; }
        public string City { get; set; }
        public string Country { get; set; }
    }</pre>



<p></p>



<h2 class="wp-block-heading" id="aioseo-client-side-code">Client-side Code</h2>



<p></p>



<p>Below is an example of client-side code,</p>



<p></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; first-line: 0; title: ; notranslate">
List&lt;UserDetails&gt; userDetails = ReadFromExcel&lt;List&lt;UserDetails&gt;&gt;(@&quot;C:\Users\TestDataRead.xlsx&quot;);
</pre></div>


<p></p>



<h3 class="wp-block-heading" id="aioseo-export-write-the-data-to-excel-file-using-epplus-api"><br><strong>Export/Write the data to an Excel file using EPPlus API </strong></h3>



<p></p>



<p>Let&#8217;s try exporting data to a new Excel file.</p>



<p>Here is the sample data/object which we want to save as an Excel file.</p>



<p></p>



<pre class="wp-block-preformatted">List&lt;UserDetails&gt; persons = new List&lt;UserDetails&gt;()
            {
                new UserDetails() {ID="9999", Name="ABCD", City ="City1", Country="USA"},
                new UserDetails() {ID="8888", Name="PQRS", City ="City2", Country="INDIA"},
                new UserDetails() {ID="7777", Name="XYZZ", City ="City3", Country="CHINA"},
                new UserDetails() {ID="6666", Name="LMNO", City ="City4", Country="UK"},
           };</pre>



<p></p>



<p>Here we need to use <em><strong>ExcelPackage </strong></em>class to create a new Excel file with the required details. </p>



<p></p>



<p>Writing data to file and creating new Excel is just a 2-3 liner code. </p>



<p></p>



<p>Please make a note of below one line doing the magic of loading DataTable into the Excel sheet </p>



<p></p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1980" height="296" src="https://i0.wp.com/thecodebuzz.com/wp-content/uploads/2019/04/Write-export-excel-in-dotnet-core-2.1-epplus.jpg?fit=785%2C117&amp;ssl=1" alt="Read/Write Excel file in .NET Core using EPPlus" class="wp-image-2604" srcset="https://thecodebuzz.com/wp-content/uploads/2019/04/Write-export-excel-in-dotnet-core-2.1-epplus.jpg 1980w, https://thecodebuzz.com/wp-content/uploads/2019/04/Write-export-excel-in-dotnet-core-2.1-epplus-300x45.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/04/Write-export-excel-in-dotnet-core-2.1-epplus-1024x153.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/04/Write-export-excel-in-dotnet-core-2.1-epplus-768x115.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/04/Write-export-excel-in-dotnet-core-2.1-epplus-1536x230.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/04/Write-export-excel-in-dotnet-core-2.1-epplus-785x117.jpg 785w" sizes="auto, (max-width: 1980px) 100vw, 1980px" /></figure>



<p></p>



<p>I am creating a new Excel file in the same project folder to keep everything simple (the Excel file will get created in the &#8216;bin&#8217; folder of the project)</p>



<p></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
private static void WriteToExcel(string path)
        {
            //Let use below test data for writing it to excel
            List&lt;UserDetails&gt; persons = new List&lt;UserDetails&gt;()
            {
                new UserDetails() {ID=&quot;9999&quot;, Name=&quot;ABCD&quot;, City =&quot;City1&quot;, Country=&quot;USA&quot;},
                new UserDetails() {ID=&quot;8888&quot;, Name=&quot;PQRS&quot;, City =&quot;City2&quot;, Country=&quot;INDIA&quot;},
                new UserDetails() {ID=&quot;7777&quot;, Name=&quot;XYZZ&quot;, City =&quot;City3&quot;, Country=&quot;CHINA&quot;},
                new UserDetails() {ID=&quot;6666&quot;, Name=&quot;LMNO&quot;, City =&quot;City4&quot;, Country=&quot;UK&quot;},
           };

            // let&#039;s convert our object data to Datatable for a simplified logic.
            // Datatable is the easiest way to deal with complex datatypes for easy reading and formatting. 
            DataTable table = (DataTable)JsonConvert.DeserializeObject(JsonConvert.SerializeObject(persons), (typeof(DataTable)));
            FileInfo filePath = new FileInfo(path);
            using (var excelPack = new ExcelPackage(filePath))
            {
                var ws = excelPack.Workbook.Worksheets.Add(&quot;WriteTest&quot;);
                ws.Cells.LoadFromDataTable(table, true, OfficeOpenXml.Table.TableStyles.Light8);
                excelPack.Save();
            }
        }

</pre></div>


<p></p>



<p>After executing the above API, a new Excel file will be created with the above custom object transformation into respective Excel columns and rows details as below,</p>



<p></p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1289" height="924" src="https://i1.wp.com/thecodebuzz.com/wp-content/uploads/2019/04/Write-to-excel-dotnet-core-epplus.jpg?fit=785%2C563&amp;ssl=1" alt="Read/Write Excel file in .NET Core using EPPlus" class="wp-image-2601" srcset="https://thecodebuzz.com/wp-content/uploads/2019/04/Write-to-excel-dotnet-core-epplus.jpg 1289w, https://thecodebuzz.com/wp-content/uploads/2019/04/Write-to-excel-dotnet-core-epplus-300x215.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/04/Write-to-excel-dotnet-core-epplus-1024x734.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/04/Write-to-excel-dotnet-core-epplus-768x551.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/04/Write-to-excel-dotnet-core-epplus-725x520.jpg 725w" sizes="auto, (max-width: 1289px) 100vw, 1289px" /></figure>



<p></p>



<p>That’s all, we just learned how to import and export data to/from Excel in the .NET Core framework.</p>



<p></p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>Above ready to use API can be used in&nbsp;.NET Core console, or test project or ASP.Net Core application&nbsp;or logic can be modified as per your requirements. Please visit the GitHub link for the complete code.</p>
</blockquote>



<p></p>



<p>I have validated the above approaches in .NET Core .NET 3.1 and found it to be working fine in all versions.</p>



<p></p>



<p><strong>Other References:</strong></p>



<p></p>



<ul class="wp-block-list">
<li>OpenXML SDK (open source SDK from Microsoft) to work with Office Word, Excel, and PowerPoint.
<ul class="wp-block-list">
<li><a href="https://www.thecodebuzz.com/read-excel-file-in-dotnet-core-2-1/" target="_blank" rel="noreferrer noopener"><strong><em>Read/Write Excel file .NET Core using OpemXML SDK</em></strong></a></li>
</ul>
</li>
</ul>



<p></p>



<ul class="wp-block-list">
<li>NPOI library for reading and writing Excel files in .NET Core,
<ul class="wp-block-list">
<li><a href="https://www.thecodebuzz.com/read-and-write-excel-file-in-net-core-using-npoi/" target="_blank" rel="noreferrer noopener"><strong><em>Read/Write Excel files in .NET Core using NPOI</em></strong></a></li>
</ul>
</li>
</ul>



<p></p>



<h2 class="wp-block-heading" id="aioseo-summary">Summary</h2>



<p></p>



<p>Today we learned, how to import and export data to/from Excel in the .NET Core framework using the <strong><em>EPPlus </em></strong>library. </p>



<p></p>



<p>The legacy so-called applications like Excel are no more legacy and can be used on any platform. <strong><em>EPPlus</em></strong> makes it easy to deal with Excel files allowing us to perform reading or create spreadsheets easily.</p>



<p></p>



<hr>



<p class=""></p>



<p class="has-background" style="background-color:#b6d9ac;font-size:18px"><br>Please <strong><em>bookmark </em></strong>this page and <em><strong>share </strong></em>it with your friends.                                                    Please <a href="https://www.thecodebuzz.com/subscription/" target="_blank" rel="noreferrer noopener"><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color"><strong>Subscribe</strong> </mark></em></a>to the blog to receive notifications on freshly published (2025) best practices and guidelines for software design and development.</p>




<br>



<hr>



<p class=""></p>



<p></p>



<p> </p><p>The post <a href="https://thecodebuzz.com/read-write-excel-in-dotnet-core-epplus/">EPPlus – How to Read/Write Excel files in C# .NET Core</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://thecodebuzz.com/read-write-excel-in-dotnet-core-epplus/feed/</wfw:commentRss>
			<slash:comments>12</slash:comments>
		
		
			</item>
		<item>
		<title>C# Read Excel file As JSON</title>
		<link>https://thecodebuzz.com/read-excel-as-json-using-open-xml-sdk/</link>
					<comments>https://thecodebuzz.com/read-excel-as-json-using-open-xml-sdk/#comments</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Thu, 08 Apr 2021 23:31:00 +0000</pubDate>
				<category><![CDATA[Excel]]></category>
		<category><![CDATA[.net core 2.0 read excel file]]></category>
		<category><![CDATA[.net core create excel file]]></category>
		<category><![CDATA[.net core excel]]></category>
		<category><![CDATA[.net core excel library]]></category>
		<category><![CDATA[.net core read excel file]]></category>
		<category><![CDATA[.netcore excel read 3.0]]></category>
		<category><![CDATA[C# read excel]]></category>
		<category><![CDATA[create Excel .net core]]></category>
		<category><![CDATA[create excel without msoffice]]></category>
		<category><![CDATA[create xlsx]]></category>
		<category><![CDATA[documentformat.openxml .net core]]></category>
		<category><![CDATA[dotnet core excel]]></category>
		<category><![CDATA[dotnet core read excel file]]></category>
		<category><![CDATA[dotnet excel]]></category>
		<category><![CDATA[Eppplus]]></category>
		<category><![CDATA[excel net core 3.0]]></category>
		<category><![CDATA[excel to datatable .net core]]></category>
		<category><![CDATA[export datatable to excel]]></category>
		<category><![CDATA[export xlsx]]></category>
		<category><![CDATA[Import and Export excel in .NET Core]]></category>
		<category><![CDATA[import xlsx]]></category>
		<category><![CDATA[net core 3.0 excel]]></category>
		<category><![CDATA[net core read excel 3.0]]></category>
		<category><![CDATA[netcore 3.0 excel]]></category>
		<category><![CDATA[open xml sdk .net core]]></category>
		<category><![CDATA[openxml .net core]]></category>
		<category><![CDATA[OpenXML SDK]]></category>
		<category><![CDATA[Read csv]]></category>
		<category><![CDATA[Read Data from excel in .NET]]></category>
		<category><![CDATA[Read excel]]></category>
		<category><![CDATA[read excel .net core]]></category>
		<category><![CDATA[read xlsx]]></category>
		<category><![CDATA[read xlsx .NET]]></category>
		<category><![CDATA[Read/Write Excel file in .NET core 2.1]]></category>
		<category><![CDATA[write xlsx]]></category>
		<guid isPermaLink="false">https://thecodebuzz.com/?p=4127</guid>

					<description><![CDATA[<p>Read Excel as JSON using Open XML SDK In our last article, we learned how to do basic Read/Write Excel using .NET Core. Today in this article we will learn how to perform a C# Excel file As JSON&#160;using Open XML SDK. Today in this article, we will cover below aspects, We shall be using [&#8230;]</p>
<p>The post <a href="https://thecodebuzz.com/read-excel-as-json-using-open-xml-sdk/">C# Read Excel file As JSON</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></description>
										<content:encoded><![CDATA[<h1 class="wp-block-heading"><strong>Read Excel as JSON using Open XML SDK</strong></h1>



<figure class="wp-block-image is-resized"><a href="https://www.thecodebuzz.com/read-excel-as-json-using-open-xml-sdk/" target="_blank" rel="noopener"><img loading="lazy" decoding="async" width="1414" height="623" src="https://i1.wp.com/thecodebuzz.com/wp-content/uploads/2019/07/Excel-as-Json-Excel-as-XML-Excel-as-Object.jpg?fit=785%2C346&amp;ssl=1" alt="C# Excel file As JSON " class="wp-image-4130" style="width:452px;height:199px" srcset="https://thecodebuzz.com/wp-content/uploads/2019/07/Excel-as-Json-Excel-as-XML-Excel-as-Object.jpg 1414w, https://thecodebuzz.com/wp-content/uploads/2019/07/Excel-as-Json-Excel-as-XML-Excel-as-Object-300x132.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/07/Excel-as-Json-Excel-as-XML-Excel-as-Object-1024x451.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/07/Excel-as-Json-Excel-as-XML-Excel-as-Object-768x338.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/07/Excel-as-Json-Excel-as-XML-Excel-as-Object-785x346.jpg 785w" sizes="auto, (max-width: 1414px) 100vw, 1414px" /></a></figure>



<p>In our last article, we learned how to do basic <a href="https://www.thecodebuzz.com/read-excel-file-in-dotnet-core-2-1/" target="_blank" rel="noreferrer noopener"><strong>Read/Write </strong></a><strong><a href="https://www.thecodebuzz.com/read-excel-file-in-dotnet-core-2-1/" target="_blank" rel="noreferrer noopener">E</a></strong><a href="https://www.thecodebuzz.com/read-excel-file-in-dotnet-core-2-1/" target="_blank" rel="noreferrer noopener"><strong>xcel using .NET Core.</strong></a> Today in this article we will learn how to perform a C# Excel file As JSON&nbsp;using Open XML SDK.</p>



<p></p>



<p></p>



<p>Today in this article, we will cover below aspects,</p>



<p></p>



<div class="wp-block-aioseo-table-of-contents"><ul><li><a href="#aioseo-c-excel-file-as-json">C# Excel file As JSON</a></li><li><a href="#aioseo-read-excel-with-empty-cell-values">Read Excel with Empty Cell values</a></li><li><a href="#aioseo-generated-json-file-output-as-below">Generated JSON file output as below</a></li></ul></div>



<p></p>



<p>We shall be using the below Excel file as an example to read. </p>



<p></p>



<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" width="1173" height="924" src="https://i0.wp.com/thecodebuzz.com/wp-content/uploads/2019/07/read-Excel-as-Json-Excel-as-XML-Excel-as-Object.jpg?fit=785%2C619&amp;ssl=1" alt="C# Read Excel(.xlsx) As JSON" class="wp-image-4131" style="width:486px;height:383px" srcset="https://thecodebuzz.com/wp-content/uploads/2019/07/read-Excel-as-Json-Excel-as-XML-Excel-as-Object.jpg 1173w, https://thecodebuzz.com/wp-content/uploads/2019/07/read-Excel-as-Json-Excel-as-XML-Excel-as-Object-300x236.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/07/read-Excel-as-Json-Excel-as-XML-Excel-as-Object-1024x807.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/07/read-Excel-as-Json-Excel-as-XML-Excel-as-Object-768x605.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/07/read-Excel-as-Json-Excel-as-XML-Excel-as-Object-660x520.jpg 660w" sizes="auto, (max-width: 1173px) 100vw, 1173px" /></figure>



<p>Let’s create a .NET Core project, here to keep it simple I am using a Console .NET Core application.</p>



<p></p>



<p>Let’s install the below package Open-XML-SDK,</p>



<p></p>



<pre class="wp-block-preformatted has-medium-font-size">PM&gt; Install-Package Open-XML-SDK -Version 2.9.0
</pre>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="2001" height="552" src="https://i1.wp.com/thecodebuzz.com/wp-content/uploads/2019/07/Read-write-excel-in-dotnet-core-1.jpg?fit=785%2C216&amp;ssl=1" alt="C# Excel as JSON " class="wp-image-4148" srcset="https://thecodebuzz.com/wp-content/uploads/2019/07/Read-write-excel-in-dotnet-core-1.jpg 2001w, https://thecodebuzz.com/wp-content/uploads/2019/07/Read-write-excel-in-dotnet-core-1-300x83.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/07/Read-write-excel-in-dotnet-core-1-1024x282.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/07/Read-write-excel-in-dotnet-core-1-768x212.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/07/Read-write-excel-in-dotnet-core-1-1536x424.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/07/Read-write-excel-in-dotnet-core-1-785x217.jpg 785w" sizes="auto, (max-width: 2001px) 100vw, 2001px" /></figure>



<p></p>



<h2 class="wp-block-heading" id="aioseo-c-excel-file-as-json">C# Excel file As JSON&nbsp;</h2>



<p></p>



<p>Let&#8217;s read the content of the Excel (<em><strong>.xlsx)</strong></em> file using the below method.</p>



<p></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
static string ReadExcelasJSON()
        {
            try
            {
                DataTable dtTable = new DataTable();
                //Lets open the existing excel file and read through its content . Open the excel using openxml sdk
                using (SpreadsheetDocument doc = SpreadsheetDocument.Open(&quot;testdata2.xlsx&quot;, false))
                {
                    //create the object for workbook part  
                    WorkbookPart workbookPart = doc.WorkbookPart;
                    Sheets thesheetcollection = workbookPart.Workbook.GetFirstChild&lt;Sheets&gt;();

                    //using for each loop to get the sheet from the sheetcollection  
                    foreach (Sheet thesheet in thesheetcollection.OfType&lt;Sheet&gt;())
                    {
                        //statement to get the worksheet object by using the sheet id  
                        Worksheet theWorksheet = ((WorksheetPart)workbookPart.GetPartById(thesheet.Id)).Worksheet;

                        SheetData thesheetdata = theWorksheet.GetFirstChild&lt;SheetData&gt;();

                      

                        for (int rCnt = 0; rCnt &lt; thesheetdata.ChildElements.Count(); rCnt++)
                        {
                            List&lt;string&gt; rowList = new List&lt;string&gt;();
                            for (int rCnt1 = 0; rCnt1
                                &lt; thesheetdata.ElementAt(rCnt).ChildElements.Count(); rCnt1++)
                            {

                                Cell thecurrentcell = (Cell)thesheetdata.ElementAt(rCnt).ChildElements.ElementAt(rCnt1);
                                //statement to take the integer value  
                                string currentcellvalue = string.Empty;
                                if (thecurrentcell.DataType != null)
                                {
                                    if (thecurrentcell.DataType == CellValues.SharedString)
                                    {
                                        int id;
                                        if (Int32.TryParse(thecurrentcell.InnerText, out id))
                                        {
                                            SharedStringItem item = workbookPart.SharedStringTablePart.SharedStringTable.Elements&lt;SharedStringItem&gt;().ElementAt(id);
                                            if (item.Text != null)
                                            {
                                                //first row will provide the column name.
                                                if (rCnt == 0)
                                                {
                                                    dtTable.Columns.Add(item.Text.Text);
                                                }
                                                else
                                                {
                                                    rowList.Add(item.Text.Text);
                                                }
                                            }
                                            else if (item.InnerText != null)
                                            {
                                                currentcellvalue = item.InnerText;
                                            }
                                            else if (item.InnerXml != null)
                                            {
                                                currentcellvalue = item.InnerXml;
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    if (rCnt != 0)//reserved for column values
                                    {
                                        rowList.Add(thecurrentcell.InnerText);
                                    }
                                }
                            }
                            if (rCnt != 0)//reserved for column values
                                dtTable.Rows.Add(rowList.ToArray());

                        }

                    }

                    return JsonConvert.SerializeObject(dtTable);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw;
            }
        }

</pre></div>


<p></p>



<p><strong>Generated sample JSON file output is as below,</strong></p>



<p></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
&#x5B;
  {
    &quot;ID&quot;: &quot;1002&quot;,
    &quot;Name&quot;: &quot;ABCD&quot;,
    &quot;City&quot;: &quot;city&quot;,
    &quot;Country&quot;: &quot;USA&quot;
  },
  {
    &quot;ID&quot;: &quot;1003&quot;,
    &quot;Name&quot;: &quot;PQRS&quot;,
    &quot;City&quot;: &quot;City&quot;,
    &quot;Country&quot;: &quot;UK&quot;
  },
  {
    &quot;ID&quot;: &quot;1004&quot;,
    &quot;Name&quot;: &quot;ZYZZ&quot;,
    &quot;City&quot;: &quot;city3&quot;,
    &quot;Country&quot;: &quot;China&quot;
  },
  {
    &quot;ID&quot;: &quot;1005&quot;,
    &quot;Name&quot;: &quot;LNMO&quot;,
    &quot;City&quot;: &quot;city4&quot;,
    &quot;Country&quot;: &quot;India&quot;
  }
]

</pre></div>


<p></p>



<h2 class="wp-block-heading" id="aioseo-read-excel-with-empty-cell-values">Read Excel with Empty Cell values </h2>



<p></p>



<p>I have left a few cell entries empty intentionally in the Excel file as below.</p>



<p></p>



<p>Let&#8217;s read the content and generate the <strong>JSON </strong>output for the same.</p>



<p></p>



<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" width="1450" height="924" src="https://i2.wp.com/thecodebuzz.com/wp-content/uploads/2019/07/read-Excel-with-empty-cell.jpg?fit=785%2C500&amp;ssl=1" alt="convert Excel as JSON" class="wp-image-4136" style="width:497px;height:316px" srcset="https://thecodebuzz.com/wp-content/uploads/2019/07/read-Excel-with-empty-cell.jpg 1450w, https://thecodebuzz.com/wp-content/uploads/2019/07/read-Excel-with-empty-cell-300x191.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/07/read-Excel-with-empty-cell-1024x653.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/07/read-Excel-with-empty-cell-768x489.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/07/read-Excel-with-empty-cell-785x500.jpg 785w" sizes="auto, (max-width: 1450px) 100vw, 1450px" /></figure>



<p></p>



<h2 class="wp-block-heading" id="aioseo-generated-json-file-output-as-below"><strong>Generated JSON file output as below</strong></h2>



<p></p>



<p>Empty fields will show as below.</p>



<p></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; highlight: [5]; title: ; notranslate">
&#x5B;
  {
    &quot;ID&quot;: &quot;1002&quot;,
    &quot;Name&quot;: &quot;ABCD&quot;,
    &quot;City&quot;: &quot;&quot;,
    &quot;Country&quot;: &quot;USA&quot;
  },
  {
    &quot;ID&quot;: &quot;1003&quot;,
    &quot;Name&quot;: &quot;PQRS&quot;,
    &quot;City&quot;: &quot;City&quot;,
    &quot;Country&quot;: &quot;UK&quot;
  },
  {
    &quot;ID&quot;: &quot;1004&quot;,
    &quot;Name&quot;: &quot;ZYZZ&quot;,
    &quot;City&quot;: &quot;city3&quot;,
    &quot;Country&quot;: &quot;China&quot;
  },
  {
    &quot;ID&quot;: &quot;1005&quot;,
    &quot;Name&quot;: &quot;LNMO&quot;,
    &quot;City&quot;: &quot;city4&quot;,
    &quot;Country&quot;: &quot;India&quot;
  }
]

</pre></div>


<p>So the above logic works perfectly fine for empty cells as well.</p>



<p></p>



<p class="has-medium-font-size">References:   <a href="https://www.thecodebuzz.com/read-and-write-excel-file-in-net-core-using-npoi/" target="_blank" rel="noreferrer noopener"><strong>Read/Write Excel using .NET Core</strong></a></p>



<p></p>



<p>Are you dealing with any complex scenarios? Please let me know and sound off your comments below! </p>



<p></p>



<hr>



<p class=""></p>



<p class="has-background" style="background-color:#b6d9ac;font-size:18px"><br>Please <strong><em>bookmark </em></strong>this page and <em><strong>share </strong></em>it with your friends.                                                    Please <a href="https://www.thecodebuzz.com/subscription/" target="_blank" rel="noreferrer noopener"><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color"><strong>Subscribe</strong> </mark></em></a>to the blog to receive notifications on freshly published (2025) best practices and guidelines for software design and development.</p>




<br>



<hr>



<p class=""></p>



<p></p><p>The post <a href="https://thecodebuzz.com/read-excel-as-json-using-open-xml-sdk/">C# Read Excel file As JSON</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://thecodebuzz.com/read-excel-as-json-using-open-xml-sdk/feed/</wfw:commentRss>
			<slash:comments>12</slash:comments>
		
		
			</item>
		<item>
		<title>How to Add Chart to Excel File</title>
		<link>https://thecodebuzz.com/how-to-add-charts-to-excel-file/</link>
					<comments>https://thecodebuzz.com/how-to-add-charts-to-excel-file/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Thu, 28 Jan 2021 04:33:00 +0000</pubDate>
				<category><![CDATA[Excel]]></category>
		<category><![CDATA[advanced excel charts and graphs templates]]></category>
		<category><![CDATA[different types of charts in excel pdf]]></category>
		<category><![CDATA[excel line graph]]></category>
		<category><![CDATA[How to Add Chart to Excel File]]></category>
		<category><![CDATA[how to create a graph in excel]]></category>
		<category><![CDATA[how to make a graph in excel from a table]]></category>
		<category><![CDATA[how to make a graph in excel with a lot of data]]></category>
		<category><![CDATA[types of charts in excel]]></category>
		<guid isPermaLink="false">https://www.thecodebuzz.com/?p=15181</guid>

					<description><![CDATA[<p>How to Add Chart to Excel File Today in this article we will see 3 simple steps to add charts to the Excel file using inbuilt excel features. This Excel feature is available out of the box and also helps you suggest several charts based on the data you are dealing with. The only thing [&#8230;]</p>
<p>The post <a href="https://thecodebuzz.com/how-to-add-charts-to-excel-file/">How to Add Chart to Excel File</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></description>
										<content:encoded><![CDATA[<h2 class="wp-block-heading" id="aioseo-how-to-add-chart-to-excel-file">How to Add Chart to Excel File</h2>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="619" src="https://www.thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-bar-charts-in-excel-2-1024x619.jpg" alt="" class="wp-image-15195" srcset="https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-bar-charts-in-excel-2-1024x619.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-bar-charts-in-excel-2-300x181.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-bar-charts-in-excel-2-768x464.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-bar-charts-in-excel-2-1536x928.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-bar-charts-in-excel-2-785x474.jpg 785w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-bar-charts-in-excel-2.jpg 1543w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Today in this article we will see 3 simple steps to add charts to the Excel file using inbuilt excel features.</p>



<p></p>



<p>This Excel feature is available out of the box and also helps you suggest several charts based on the data you are dealing with. </p>



<p></p>



<p>The only thing you need to do is select the data collection and get the required charts on the screen as simple as that.</p>



<p></p>



<h2 class="wp-block-heading" id="aioseo-getting-started">Getting started </h2>



<p></p>



<p>Let&#8217;s Open the excel file and below sample data.</p>



<p></p>



<p> I have a simple Excel file with <strong><em>Population </em></strong>data as below,</p>



<p></p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="809" src="https://www.thecodebuzz.com/wp-content/uploads/2021/03/How-to-add-charts-to-excel-file-1024x809.jpg" alt="" class="wp-image-15183" style="width:415px;height:328px" srcset="https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-add-charts-to-excel-file-1024x809.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-add-charts-to-excel-file-300x237.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-add-charts-to-excel-file-768x607.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-add-charts-to-excel-file-658x520.jpg 658w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-add-charts-to-excel-file.jpg 1367w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">How to add charts to Excel file</figcaption></figure>



<p></p>



<p>Next simple step is to -&gt;click with in data anywhere followed by click on  -&gt;<strong><em>Insert</em></strong>.</p>



<p></p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="270" src="https://www.thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-charts-in-excel-file-1024x270.jpg" alt="" class="wp-image-15184" style="width:516px;height:135px" srcset="https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-charts-in-excel-file-1024x270.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-charts-in-excel-file-300x79.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-charts-in-excel-file-768x203.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-charts-in-excel-file-785x207.jpg 785w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-charts-in-excel-file.jpg 1113w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p></p>



<p>Next just click on the-&gt; <strong><em>Recommended Charts</em></strong></p>



<p></p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="142" src="https://www.thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-pie-charts-in-excel-file-1024x142.jpg" alt="" class="wp-image-15185" style="width:549px;height:76px" srcset="https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-pie-charts-in-excel-file-1024x142.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-pie-charts-in-excel-file-300x41.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-pie-charts-in-excel-file-768x106.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-pie-charts-in-excel-file-1536x212.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-pie-charts-in-excel-file-785x109.jpg 785w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-pie-charts-in-excel-file.jpg 1888w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p></p>



<p>Now excel will give you choice for multiple charts automatically like Line charts, pie charts or bar charts, etc.</p>



<p></p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="961" src="https://www.thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-pie-charts-in-excel-1024x961.jpg" alt="" class="wp-image-15187" style="width:456px;height:428px" srcset="https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-pie-charts-in-excel-1024x961.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-pie-charts-in-excel-300x281.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-pie-charts-in-excel-768x721.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-pie-charts-in-excel-554x520.jpg 554w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-pie-charts-in-excel.jpg 1279w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p></p>



<p><strong><em>Example Pie Charts ,</em></strong></p>



<p></p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="805" src="https://www.thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-bar-charts-in-excel-file-1024x805.jpg" alt="" class="wp-image-15188" style="width:527px;height:413px" srcset="https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-bar-charts-in-excel-file-1024x805.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-bar-charts-in-excel-file-300x236.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-bar-charts-in-excel-file-768x604.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-bar-charts-in-excel-file-662x520.jpg 662w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-bar-charts-in-excel-file.jpg 1527w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p></p>



<p><strong><em>Example bar Charts ,</em></strong></p>



<p></p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="491" src="https://www.thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-bar-charts-in-excel-1024x491.jpg" alt="" class="wp-image-15189" style="width:522px;height:250px" srcset="https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-bar-charts-in-excel-1024x491.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-bar-charts-in-excel-300x144.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-bar-charts-in-excel-768x368.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-bar-charts-in-excel-1536x737.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-bar-charts-in-excel-2048x983.jpg 2048w, https://thecodebuzz.com/wp-content/uploads/2021/03/How-to-create-bar-charts-in-excel-785x377.jpg 785w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p></p>



<p style="font-size:18px">Do you have any <strong>comments or ideas or any better </strong>suggestions to share?</p>



<p class="has-small-font-size"></p>



<p style="font-size:18px">Please sound off your comments below.</p>



<p class="has-medium-font-size"></p>



<p class="has-medium-font-size"><strong>Happy Coding </strong>!!</p>



<p></p>



<hr>



<p class=""></p>



<p class="has-background" style="background-color:#b6d9ac;font-size:18px"><br>Please <strong><em>bookmark </em></strong>this page and <em><strong>share </strong></em>it with your friends.                                                    Please <a href="https://www.thecodebuzz.com/subscription/" target="_blank" rel="noreferrer noopener"><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color"><strong>Subscribe</strong> </mark></em></a>to the blog to receive notifications on freshly published (2025) best practices and guidelines for software design and development.</p>




<br>



<hr>



<p class=""></p>



<p></p><p>The post <a href="https://thecodebuzz.com/how-to-add-charts-to-excel-file/">How to Add Chart to Excel File</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://thecodebuzz.com/how-to-add-charts-to-excel-file/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
