<?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>Spire.XLS &#8211; Sibeesh Passion</title>
	<atom:link href="https://sibeeshpassion.com/category/products/spire-xls/feed/" rel="self" type="application/rss+xml" />
	<link>https://sibeeshpassion.com</link>
	<description>My passion towards life</description>
	<lastBuildDate>Wed, 02 Jun 2021 15:16:32 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>/wp-content/uploads/2017/04/Sibeesh_Passion_Logo_Small.png</url>
	<title>Spire.XLS &#8211; Sibeesh Passion</title>
	<link>https://sibeeshpassion.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Working With Charts Using Spire.XLS</title>
		<link>https://sibeeshpassion.com/working-with-charts-using-spire-xls/</link>
					<comments>https://sibeeshpassion.com/working-with-charts-using-spire-xls/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Tue, 11 Aug 2015 15:45:19 +0000</pubDate>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Products]]></category>
		<category><![CDATA[Spire.XLS]]></category>
		<category><![CDATA[VB.Net]]></category>
		<category><![CDATA[chart]]></category>
		<category><![CDATA[Charts Using Spire.XLS]]></category>
		<category><![CDATA[Column Charts]]></category>
		<category><![CDATA[Pie Charts]]></category>
		<category><![CDATA[Save Excel Charts as Images]]></category>
		<category><![CDATA[Spire.XLs]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=8751</guid>

					<description><![CDATA[Today we are going to see an another series of new product Spire.XLS which helps us to create, manipulate, convert EXCEL file to other formats, create charts dynamically and many more. This product has been introduced by the company E-Iceblue. I hope you have read my article of Spire.Doc and Spire.XLS. If you have not read it, I recommend you to read it here: Using Spire.XLS Background As you all know, charts are the graphical representations of our data. It is much easier to understand our data if it is in a graphical form. Am I right? It is easy [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Today we are going to see an another series of new product <em>Spire.XLS</em> which helps us to create, manipulate, convert EXCEL file to other formats, create charts dynamically and many more. This product has been introduced by the company <a href="http://www.e-iceblue.com/" target="_blank" rel="noopener">E-Iceblue</a>. I hope you have read my article of <em>Spire.Doc</em> and <em>Spire.XLS</em>. If you have not read it, I recommend you to read it here: <a href="http://sibeeshpassion.com/using-spire-xls/" target="_blank" rel="noopener">Using Spire.XLS</a></p>
<p><strong>Background</strong></p>
<p>As you all know, charts are the graphical representations of our data. It is much easier to understand our data if it is in a graphical form. Am I right? It is easy to create a static chart, but what about a dynamic one? It will be bit tough right? But by using Spire.XLS, we can create any kind of charts easily. In this post, we will see those implementations. </p>
<p><strong>Download the files</strong></p>
<p>You can always get the needed files from here: <a href="http://www.e-iceblue.com/Download/download-excel-for-net-now.html" target="_blank" rel="noopener">Download Spire.XLS</a></p>
<p><strong>Install Spire.XLS</strong></p>
<p>I am using evaluation version with one month temporary license. There are free versions also available for spire.xls with some limitation. You can try that. Now click on the exe file after you extract the downloaded file. The installation will get started then.</p>
<p><img decoding="async" src="http://sibeeshpassion.com/content/images/InstallSpireXls.png" alt="Using Spire XLS" /></p>
<p><strong>Using the code</strong></p>
<p>Before starting with coding you need to add the needed namespaces as follows.</p>
<p>[csharp]<br />
using Spire.Xls;<br />
using System.Drawing;<br />
[/csharp]</p>
<p>First of all create a form and then a button, in the button click add the following lines of codes.</p>
<p><strong>C# Code</strong></p>
<p>[csharp]<br />
  private void button1_Click(object sender, EventArgs e)<br />
        {<br />
            try<br />
            {<br />
                //Create a new workbook<br />
                Workbook workbook = new Workbook();<br />
                //Initialize worksheet<br />
                workbook.CreateEmptySheets(1);<br />
                Worksheet sheet = workbook.Worksheets[0];<br />
                //Set sheet name<br />
                sheet.Name = &quot;Chart data&quot;;<br />
                //Set the grid lines invisible<br />
                sheet.GridLinesVisible = false;<br />
                //Create a chart<br />
                Chart chart = sheet.Charts.Add(ExcelChartType.Pie3D);<br />
                //Set region of chart data<br />
                chart.DataRange = sheet.Range[&quot;B2:B5&quot;];<br />
                chart.SeriesDataFromRange = false;<br />
                //Set position of chart<br />
                chart.LeftColumn = 1;<br />
                chart.TopRow = 6;<br />
                chart.RightColumn = 9;<br />
                chart.BottomRow = 25;<br />
                //Chart title<br />
                chart.ChartTitle = &quot;Sales by year&quot;;<br />
                chart.ChartTitleArea.IsBold = true;<br />
                chart.ChartTitleArea.Size = 12;<br />
                //Initialize the chart series<br />
                Spire.Xls.Charts.ChartSerie cs = chart.Series[0];<br />
                //Chart Labels resource<br />
                cs.CategoryLabels = sheet.Range[&quot;A2:A5&quot;];<br />
                //Chart value resource<br />
                cs.Values = sheet.Range[&quot;B2:B5&quot;];<br />
                //Set the value visible in the chart<br />
                cs.DataPoints.DefaultDataPoint.DataLabels.HasValue = true;<br />
                //Year<br />
                sheet.Range[&quot;A1&quot;].Value = &quot;Year&quot;;<br />
                sheet.Range[&quot;A2&quot;].Value = &quot;2002&quot;;<br />
                sheet.Range[&quot;A3&quot;].Value = &quot;2003&quot;;<br />
                sheet.Range[&quot;A4&quot;].Value = &quot;2004&quot;;<br />
                sheet.Range[&quot;A5&quot;].Value = &quot;2005&quot;;<br />
                //Sales<br />
                sheet.Range[&quot;B1&quot;].Value = &quot;Sales&quot;;<br />
                sheet.Range[&quot;B2&quot;].NumberValue = 4000;<br />
                sheet.Range[&quot;B3&quot;].NumberValue = 6000;<br />
                sheet.Range[&quot;B4&quot;].NumberValue = 7000;<br />
                sheet.Range[&quot;B5&quot;].NumberValue = 8500;<br />
                //Style<br />
                sheet.Range[&quot;A1:B1&quot;].Style.Font.IsBold = true;<br />
                sheet.Range[&quot;A2:B2&quot;].Style.KnownColor = ExcelColors.LightYellow;<br />
                sheet.Range[&quot;A3:B3&quot;].Style.KnownColor = ExcelColors.LightGreen1;<br />
                sheet.Range[&quot;A4:B4&quot;].Style.KnownColor = ExcelColors.LightOrange;<br />
                sheet.Range[&quot;A5:B5&quot;].Style.KnownColor = ExcelColors.LightTurquoise;<br />
                //Border<br />
                sheet.Range[&quot;A1:B5&quot;].Style.Borders[BordersLineType.EdgeTop].Color = Color.FromArgb(0, 0, 128);<br />
                sheet.Range[&quot;A1:B5&quot;].Style.Borders[BordersLineType.EdgeTop].LineStyle = LineStyleType.Thin;<br />
                sheet.Range[&quot;A1:B5&quot;].Style.Borders[BordersLineType.EdgeBottom].Color = Color.FromArgb(0, 0, 128);<br />
                sheet.Range[&quot;A1:B5&quot;].Style.Borders[BordersLineType.EdgeBottom].LineStyle = LineStyleType.Thin;<br />
                sheet.Range[&quot;A1:B5&quot;].Style.Borders[BordersLineType.EdgeLeft].Color = Color.FromArgb(0, 0, 128);<br />
                sheet.Range[&quot;A1:B5&quot;].Style.Borders[BordersLineType.EdgeLeft].LineStyle = LineStyleType.Thin;<br />
                sheet.Range[&quot;A1:B5&quot;].Style.Borders[BordersLineType.EdgeRight].Color = Color.FromArgb(0, 0, 128);<br />
                sheet.Range[&quot;A1:B5&quot;].Style.Borders[BordersLineType.EdgeRight].LineStyle = LineStyleType.Thin;<br />
                //Number format<br />
                sheet.Range[&quot;B2:C5&quot;].Style.NumberFormat = &quot;\&quot;$\&quot;#,##0&quot;;<br />
                chart.PlotArea.Fill.Visible = false;<br />
                //Save the file<br />
                workbook.SaveToFile(&quot;Sample.xls&quot;);<br />
                //Launch the file<br />
                System.Diagnostics.Process.Start(&quot;Sample.xls&quot;);<br />
            }<br />
            catch (Exception)<br />
            {</p>
<p>                throw;<br />
            }<br />
        }<br />
[/csharp]</p>
<p><strong>VB.NET Code</strong></p>
<p>[vb]<br />
 &#8216;Create a new workbook<br />
        Dim workbook As New Workbook()<br />
        &#8216;Initialize worksheet<br />
        workbook.CreateEmptySheets(1)<br />
        Dim sheet As Worksheet = workbook.Worksheets(0)<br />
        &#8216;Set sheet name<br />
        sheet.Name = &quot;Chart data&quot;<br />
        &#8216;Set the grid lines invisible<br />
        sheet.GridLinesVisible = False<br />
        &#8216;Create a chart<br />
        Dim chart As Chart = sheet.Charts.Add(ExcelChartType.Pie3D)<br />
        &#8216;Set region of chart data<br />
        chart.DataRange = sheet.Range(&quot;B2:B5&quot;)<br />
        chart.SeriesDataFromRange = False<br />
        &#8216;Set position of chart<br />
        chart.LeftColumn = 1<br />
        chart.TopRow = 6<br />
        chart.RightColumn = 9<br />
        chart.BottomRow = 25<br />
        &#8216;Chart title<br />
        chart.ChartTitle = &quot;Sales by year&quot;<br />
        chart.ChartTitleArea.IsBold = True<br />
        chart.ChartTitleArea.Size = 12<br />
        &#8216;Set the chart<br />
        Dim cs As Spire.Xls.Charts.ChartSerie = chart.Series(0)<br />
        &#8216;Chart Labels resource<br />
        cs.CategoryLabels = sheet.Range(&quot;A2:A5&quot;)<br />
        &#8216;Chart value resource<br />
        cs.Values = sheet.Range(&quot;B2:B5&quot;)<br />
        &#8216;Set the value visible in the chart<br />
        cs.DataPoints.DefaultDataPoint.DataLabels.HasValue = True<br />
        &#8216;Year<br />
        sheet.Range(&quot;A1&quot;).Value = &quot;Year&quot;<br />
        sheet.Range(&quot;A2&quot;).Value = &quot;2002&quot;<br />
        sheet.Range(&quot;A3&quot;).Value = &quot;2003&quot;<br />
        sheet.Range(&quot;A4&quot;).Value = &quot;2004&quot;<br />
        sheet.Range(&quot;A5&quot;).Value = &quot;2005&quot;<br />
        &#8216;Sales<br />
        sheet.Range(&quot;B1&quot;).Value = &quot;Sales&quot;<br />
        sheet.Range(&quot;B2&quot;).NumberValue = 4000<br />
        sheet.Range(&quot;B3&quot;).NumberValue = 6000<br />
        sheet.Range(&quot;B4&quot;).NumberValue = 7000<br />
        sheet.Range(&quot;B5&quot;).NumberValue = 8500<br />
        &#8216;Style<br />
        sheet.Range(&quot;A1:B1&quot;).Style.Font.IsBold = True<br />
        sheet.Range(&quot;A2:B2&quot;).Style.KnownColor = ExcelColors.LightYellow<br />
        sheet.Range(&quot;A3:B3&quot;).Style.KnownColor = ExcelColors.LightGreen1<br />
        sheet.Range(&quot;A4:B4&quot;).Style.KnownColor = ExcelColors.LightOrange<br />
        sheet.Range(&quot;A5:B5&quot;).Style.KnownColor = ExcelColors.LightTurquoise<br />
        &#8216;Border<br />
        sheet.Range(&quot;A1:B5&quot;).Style.Borders(BordersLineType.EdgeTop).Color = Color.FromArgb(0, 0, 128)<br />
        sheet.Range(&quot;A1:B5&quot;).Style.Borders(BordersLineType.EdgeTop).LineStyle = LineStyleType.Thin<br />
        sheet.Range(&quot;A1:B5&quot;).Style.Borders(BordersLineType.EdgeBottom).Color = Color.FromArgb(0, 0, 128)<br />
        sheet.Range(&quot;A1:B5&quot;).Style.Borders(BordersLineType.EdgeBottom).LineStyle = LineStyleType.Thin<br />
        sheet.Range(&quot;A1:B5&quot;).Style.Borders(BordersLineType.EdgeLeft).Color = Color.FromArgb(0, 0, 128)<br />
        sheet.Range(&quot;A1:B5&quot;).Style.Borders(BordersLineType.EdgeLeft).LineStyle = LineStyleType.Thin<br />
        sheet.Range(&quot;A1:B5&quot;).Style.Borders(BordersLineType.EdgeRight).Color = Color.FromArgb(0, 0, 128)<br />
        sheet.Range(&quot;A1:B5&quot;).Style.Borders(BordersLineType.EdgeRight).LineStyle = LineStyleType.Thin<br />
        &#8216;Number format<br />
        sheet.Range(&quot;B2:C5&quot;).Style.NumberFormat = &quot;&quot;&quot;$&quot;&quot;#,##0&quot;<br />
        chart.PlotArea.Fill.Visible = False<br />
        &#8216;Save doc file.<br />
        workbook.SaveToFile(&quot;Sample.xls&quot;)<br />
        &#8216;Launch the MS Word file.<br />
        System.Diagnostics.Process.Start(&quot;Sample.xls&quot;)<br />
[/vb]</p>
<p>In the above lines code, we are creating a pie chart by giving some settings and data and load it. Now if you run you will get an output as follows.</p>
<p><a href="http://sibeeshpassion.com/wp-content/uploads/2015/08/Create_Charts_Using_SpireXLS-e1439222337541.png"><img fetchpriority="high" decoding="async" src="http://sibeeshpassion.com/wp-content/uploads/2015/08/Create_Charts_Using_SpireXLS-e1439222337541.png" alt="Create_Charts_Using_SpireXLS" width="650" height="261" class="alignnone size-full wp-image-8761" srcset="/wp-content/uploads/2015/08/Create_Charts_Using_SpireXLS-e1439222337541.png 650w, /wp-content/uploads/2015/08/Create_Charts_Using_SpireXLS-e1439222337541-300x120.png 300w, /wp-content/uploads/2015/08/Create_Charts_Using_SpireXLS-e1439222337541-400x161.png 400w" sizes="(max-width: 650px) 100vw, 650px" /></a></p>
<p><a href="http://sibeeshpassion.com/wp-content/uploads/2015/08/Create_Charts_Using_SpireXLS_Output.png"><img decoding="async" src="http://sibeeshpassion.com/wp-content/uploads/2015/08/Create_Charts_Using_SpireXLS_Output.png" alt="Create_Charts_Using_SpireXLS_Output" width="581" height="510" class="alignnone size-full wp-image-8771" srcset="/wp-content/uploads/2015/08/Create_Charts_Using_SpireXLS_Output.png 581w, /wp-content/uploads/2015/08/Create_Charts_Using_SpireXLS_Output-300x263.png 300w, /wp-content/uploads/2015/08/Create_Charts_Using_SpireXLS_Output-400x351.png 400w" sizes="(max-width: 581px) 100vw, 581px" /></a></p>
<p>In the above mentioned lines of codes, we are doing so many processes, those processes are listed below.</p>
<li>Creating a new workbook</li>
<li>Initialize worksheet newly created</li>
<li>Set sheet name of worksheet</li>
<li>Set the grid lines invisible</li>
<li>Creating a chart</li>
<li>Set region of chart data</li>
<li>Set position of chart</li>
<li>Set Chart title</li>
<li>Initialize the chart series</li>
<li>Setting Chart Labels resource</li>
<li>Setting Chart value resource</li>
<li>Set the value visible in the chart</li>
<li>Apply Styles</li>
<li>Apply Borders</li>
<li>Give Number format if necessary</li>
<li>Save the file</li>
<li>At last Launch the file</li>
<p>Wow!. That&#8217;s cool right?</p>
<p>Not yet finished!. There are so many things you can try with your sheet object. I suggest you to try those. You will get surprised.</p>
<div id="attachment_10031" style="width: 660px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/08/Working_With_Charts_Using_Spire-e1440082383956.png"><img decoding="async" aria-describedby="caption-attachment-10031" src="http://sibeeshpassion.com/wp-content/uploads/2015/08/Working_With_Charts_Using_Spire-e1440082383956.png" alt="Working With Charts Using Spire XLS Sheet Object" width="650" height="233" class="size-full wp-image-10031" srcset="/wp-content/uploads/2015/08/Working_With_Charts_Using_Spire-e1440082383956.png 650w, /wp-content/uploads/2015/08/Working_With_Charts_Using_Spire-e1440082383956-300x108.png 300w, /wp-content/uploads/2015/08/Working_With_Charts_Using_Spire-e1440082383956-400x143.png 400w" sizes="(max-width: 650px) 100vw, 650px" /></a><p id="caption-attachment-10031" class="wp-caption-text">Working With Charts Using Spire XLS Sheet Object</p></div>
<div id="attachment_10041" style="width: 660px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/08/Working_With_Charts_Using_Spire1-e1440082428977.png"><img decoding="async" aria-describedby="caption-attachment-10041" src="http://sibeeshpassion.com/wp-content/uploads/2015/08/Working_With_Charts_Using_Spire1-e1440082428977.png" alt="Working With Charts Using Spire XLS Sheet Object" width="650" height="270" class="size-full wp-image-10041" srcset="/wp-content/uploads/2015/08/Working_With_Charts_Using_Spire1-e1440082428977.png 650w, /wp-content/uploads/2015/08/Working_With_Charts_Using_Spire1-e1440082428977-300x125.png 300w, /wp-content/uploads/2015/08/Working_With_Charts_Using_Spire1-e1440082428977-400x166.png 400w" sizes="(max-width: 650px) 100vw, 650px" /></a><p id="caption-attachment-10041" class="wp-caption-text">Working With Charts Using Spire XLS Sheet Object</p></div>
<p>If you want you can set different chart types too, it will give you a great design in your chart. The most useful chart types which I uses is Bar3DClustered, 3DBubble, Bubble, Column3D and many more.</p>
<div id="attachment_10051" style="width: 660px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/08/Working_With_Charts_Using_Spire_XLS_Chart_Object.png"><img decoding="async" aria-describedby="caption-attachment-10051" src="http://sibeeshpassion.com/wp-content/uploads/2015/08/Working_With_Charts_Using_Spire_XLS_Chart_Object-e1440082676189.png" alt="Working_With_Charts_Using_Spire_XLS_Chart_Object" width="650" height="195" class="size-full wp-image-10051" srcset="/wp-content/uploads/2015/08/Working_With_Charts_Using_Spire_XLS_Chart_Object-e1440082676189.png 650w, /wp-content/uploads/2015/08/Working_With_Charts_Using_Spire_XLS_Chart_Object-e1440082676189-300x90.png 300w, /wp-content/uploads/2015/08/Working_With_Charts_Using_Spire_XLS_Chart_Object-e1440082676189-400x120.png 400w" sizes="(max-width: 650px) 100vw, 650px" /></a><p id="caption-attachment-10051" class="wp-caption-text">Working_With_Charts_Using_Spire_XLS_Chart_Object</p></div>
<p>This product gives you many ways to make your chart in the way you like. There are plenty of options available to so so like you can set the Legend Position by using LegendPositionType property.</p>
<p>Next we will see how we can implement Column chart, what ever we have discusses will be same for every charts, but it may have some different properties which is strictly depends on the chart type. </p>
<p><strong>Column Chart</strong></p>
<p>Now we will create an another button and name it Column Chart. And in the button click you need to add the following codes.</p>
<p><strong>C# Code</strong></p>
<p>[csharp]<br />
private void button2_Click(object sender, EventArgs e)<br />
        {<br />
            try<br />
            {<br />
                //Load Workbook<br />
                Workbook workbook = new Workbook();<br />
                workbook.LoadFromFile(@&quot;D:\Sample.xlsx&quot;);<br />
                Worksheet sheet = workbook.Worksheets[0];<br />
                //Add Chart and Set Chart Data Range<br />
                Chart chart = sheet.Charts.Add(ExcelChartType.ColumnClustered);<br />
                chart.DataRange = sheet.Range[&quot;D1:E17&quot;];<br />
                chart.SeriesDataFromRange = false;<br />
                //Chart Position<br />
                chart.LeftColumn = 1;<br />
                chart.TopRow = 19;<br />
                chart.RightColumn = 8;<br />
                chart.BottomRow = 33;<br />
                //Chart Border<br />
                chart.ChartArea.Border.Weight = ChartLineWeightType.Medium;<br />
                chart.ChartArea.Border.Color = Color.SandyBrown;<br />
                //Chart Title<br />
                chart.ChartTitle = &quot;Parts Sales Info&quot;;<br />
                chart.ChartTitleArea.Font.FontName = &quot;Calibri&quot;;<br />
                chart.ChartTitleArea.Font.Size = 13;<br />
                chart.ChartTitleArea.Font.IsBold = true;<br />
                //Chart Axes<br />
                chart.PrimaryCategoryAxis.Title = &quot;Parts&quot;;<br />
                chart.PrimaryCategoryAxis.Font.Color = Color.Blue;<br />
                chart.PrimaryValueAxis.Title = &quot;Amounts&quot;;<br />
                chart.PrimaryValueAxis.HasMajorGridLines = false;<br />
                chart.PrimaryValueAxis.MaxValue = 350;<br />
                chart.PrimaryValueAxis.TitleArea.TextRotationAngle = 90;<br />
                //Chart Legend<br />
                chart.Legend.Position = LegendPositionType.Right;<br />
                //Save and Launch<br />
                workbook.SaveToFile(&quot;ExcelColumnChart.xlsx&quot;, ExcelVersion.Version2010);<br />
                System.Diagnostics.Process.Start(&quot;ExcelColumnChart.xlsx&quot;);</p>
<p>            }<br />
            catch (Exception)<br />
            {</p>
<p>                throw;<br />
            }<br />
        }<br />
[/csharp]</p>
<p><strong>VB.NET Code</strong></p>
<p>[vb]<br />
 &#8216;Load Workbook<br />
            Dim workbook As New Workbook()<br />
            workbook.LoadFromFile(&quot;E:\Sample.xlsx&quot;)<br />
            Dim sheet As Worksheet = workbook.Worksheets(0)<br />
            &#8216;Add Chart and Set Chart Data Range<br />
            Dim chart As Chart = sheet.Charts.Add(ExcelChartType.ColumnClustered)<br />
            chart.DataRange = sheet.Range(&quot;D1:E17&quot;)<br />
            chart.SeriesDataFromRange = False<br />
            &#8216;Chart Position<br />
            chart.LeftColumn = 1<br />
            chart.TopRow = 19<br />
            chart.RightColumn = 8<br />
            chart.BottomRow = 33<br />
            &#8216;Chart Border<br />
            chart.ChartArea.Border.Weight = ChartLineWeightType.Medium<br />
            chart.ChartArea.Border.Color = Color.SandyBrown<br />
            &#8216;Chart Title<br />
            chart.ChartTitle = &quot;Parts Sales Info&quot;<br />
            chart.ChartTitleArea.Font.FontName = &quot;Calibri&quot;<br />
            chart.ChartTitleArea.Font.Size = 13<br />
            chart.ChartTitleArea.Font.IsBold = True<br />
            &#8216;Chart Axes<br />
            chart.PrimaryCategoryAxis.Title = &quot;Parts&quot;<br />
            chart.PrimaryCategoryAxis.Font.Color = Color.Blue<br />
            chart.PrimaryValueAxis.Title = &quot;Amounts&quot;<br />
            chart.PrimaryValueAxis.HasMajorGridLines = False<br />
            chart.PrimaryValueAxis.MaxValue = 350<br />
            chart.PrimaryValueAxis.TitleArea.TextRotationAngle = 90<br />
            &#8216;Chart Legend<br />
            chart.Legend.Position = LegendPositionType.Right<br />
            &#8216;Save and Launch<br />
            workbook.SaveToFile(&quot;ExcelColumnChart.xlsx&quot;, ExcelVersion.Version2010)<br />
            System.Diagnostics.Process.Start(&quot;ExcelColumnChart.xlsx&quot;)</p>
<p>[/vb]</p>
<p>Now if you run the code, you can see an output as follows.</p>
<p><a href="http://sibeeshpassion.com/wp-content/uploads/2015/08/columnchart-e1439304127270.png"><img decoding="async" src="http://sibeeshpassion.com/wp-content/uploads/2015/08/columnchart-e1439304127270.png" alt="columnchart" width="650" height="398" class="alignnone size-full wp-image-9061" srcset="/wp-content/uploads/2015/08/columnchart-e1439304127270.png 650w, /wp-content/uploads/2015/08/columnchart-e1439304127270-300x184.png 300w, /wp-content/uploads/2015/08/columnchart-e1439304127270-400x245.png 400w" sizes="(max-width: 650px) 100vw, 650px" /></a></p>
<p><strong>Excel Bar Chart</strong></p>
<p>Before going through you must add an new namespace as follows.</p>
<p>[csharp]<br />
using Spire.Xls.Charts;<br />
[/csharp]<br />
Now we will create an another button in our form and in the click event we will write the receding lines of codes.</p>
<p>[csharp]<br />
  private void button1_Click(object sender, EventArgs e)<br />
        {<br />
            try<br />
            {<br />
                Workbook workbook = new Workbook();<br />
                //Initailize worksheet<br />
                workbook.CreateEmptySheets(1);<br />
                Worksheet sheet = workbook.Worksheets[0];<br />
                sheet.Name = &quot;Chart data&quot;;<br />
                sheet.GridLinesVisible = false;<br />
                //Writes chart data<br />
                CreateChartData(sheet);<br />
                //Add a new  chart worsheet to workbook<br />
                Chart chart = sheet.Charts.Add();<br />
                //Set region of chart data<br />
                chart.DataRange = sheet.Range[&quot;A1:C5&quot;];<br />
                chart.SeriesDataFromRange = false;<br />
                //Set position of chart<br />
                chart.LeftColumn = 1;<br />
                chart.TopRow = 6;<br />
                chart.RightColumn = 11;<br />
                chart.BottomRow = 29;<br />
                chart.ChartType = ExcelChartType.Bar3DClustered;<br />
                //Chart title<br />
                chart.ChartTitle = &quot;Sales market by country&quot;;<br />
                chart.ChartTitleArea.IsBold = true;<br />
                chart.ChartTitleArea.Size = 12;<br />
                chart.PrimaryCategoryAxis.Title = &quot;Country&quot;;<br />
                chart.PrimaryCategoryAxis.Font.IsBold = true;<br />
                chart.PrimaryCategoryAxis.TitleArea.IsBold = true;<br />
                chart.PrimaryCategoryAxis.TitleArea.TextRotationAngle = 90;<br />
                chart.PrimaryValueAxis.Title = &quot;Sales(in Dollars)&quot;;<br />
                chart.PrimaryValueAxis.HasMajorGridLines = false;<br />
                chart.PrimaryValueAxis.MinValue = 1000;<br />
                chart.PrimaryValueAxis.TitleArea.IsBold = true;<br />
                foreach (ChartSerie cs in chart.Series)<br />
                {<br />
                    cs.Format.Options.IsVaryColor = true;<br />
                    cs.DataPoints.DefaultDataPoint.DataLabels.HasValue = true;<br />
                }<br />
                chart.Legend.Position = LegendPositionType.Top;<br />
                workbook.SaveToFile(&quot;Sample.xls&quot;);<br />
                ExcelDocViewer(workbook.FileName);</p>
<p>            }<br />
            catch (Exception)<br />
            {<br />
                throw;<br />
            }<br />
        }<br />
[/csharp]</p>
<p>As you can see we are calling a function <em>CreateChartData</em> to generate the data, so now we will write the function body.</p>
<p>[csharp]<br />
private void CreateChartData(Worksheet sheet)<br />
        {<br />
            //Country<br />
            sheet.Range[&quot;A1&quot;].Value = &quot;Country&quot;;<br />
            sheet.Range[&quot;A2&quot;].Value = &quot;Cuba&quot;;<br />
            sheet.Range[&quot;A3&quot;].Value = &quot;Mexico&quot;;<br />
            sheet.Range[&quot;A4&quot;].Value = &quot;France&quot;;<br />
            sheet.Range[&quot;A5&quot;].Value = &quot;German&quot;;<br />
            //Jun<br />
            sheet.Range[&quot;B1&quot;].Value = &quot;Jun&quot;;<br />
            sheet.Range[&quot;B2&quot;].NumberValue = 6000;<br />
            sheet.Range[&quot;B3&quot;].NumberValue = 8000;<br />
            sheet.Range[&quot;B4&quot;].NumberValue = 9000;<br />
            sheet.Range[&quot;B5&quot;].NumberValue = 8500;<br />
            //Jun<br />
            sheet.Range[&quot;C1&quot;].Value = &quot;Aug&quot;;<br />
            sheet.Range[&quot;C2&quot;].NumberValue = 3000;<br />
            sheet.Range[&quot;C3&quot;].NumberValue = 2000;<br />
            sheet.Range[&quot;C4&quot;].NumberValue = 2300;<br />
            sheet.Range[&quot;C5&quot;].NumberValue = 4200;<br />
            //Style<br />
            sheet.Range[&quot;A1:C1&quot;].Style.Font.IsBold = true;<br />
            sheet.Range[&quot;A2:C2&quot;].Style.KnownColor = ExcelColors.LightYellow;<br />
            sheet.Range[&quot;A3:C3&quot;].Style.KnownColor = ExcelColors.LightGreen1;<br />
            sheet.Range[&quot;A4:C4&quot;].Style.KnownColor = ExcelColors.LightOrange;<br />
            sheet.Range[&quot;A5:C5&quot;].Style.KnownColor = ExcelColors.LightTurquoise;<br />
            //Border<br />
            sheet.Range[&quot;A1:C5&quot;].Style.Borders[BordersLineType.EdgeTop].Color = Color.FromArgb(0, 0, 128);<br />
            sheet.Range[&quot;A1:C5&quot;].Style.Borders[BordersLineType.EdgeTop].LineStyle = LineStyleType.Thin;<br />
            sheet.Range[&quot;A1:C5&quot;].Style.Borders[BordersLineType.EdgeBottom].Color = Color.FromArgb(0, 0, 128);<br />
            sheet.Range[&quot;A1:C5&quot;].Style.Borders[BordersLineType.EdgeBottom].LineStyle = LineStyleType.Thin;<br />
            sheet.Range[&quot;A1:C5&quot;].Style.Borders[BordersLineType.EdgeLeft].Color = Color.FromArgb(0, 0, 128);<br />
            sheet.Range[&quot;A1:C5&quot;].Style.Borders[BordersLineType.EdgeLeft].LineStyle = LineStyleType.Thin;<br />
            sheet.Range[&quot;A1:C5&quot;].Style.Borders[BordersLineType.EdgeRight].Color = Color.FromArgb(0, 0, 128);<br />
            sheet.Range[&quot;A1:C5&quot;].Style.Borders[BordersLineType.EdgeRight].LineStyle = LineStyleType.Thin;<br />
            sheet.Range[&quot;B2:C5&quot;].Style.NumberFormat = &quot;\&quot;$\&quot;#,##0&quot;;<br />
        }<br />
[/csharp]</p>
<p>And we will use the preceding function for viewing our chart created.</p>
<p>[csharp]<br />
private void ExcelDocViewer(string fileName)<br />
        {<br />
            try<br />
            {<br />
                System.Diagnostics.Process.Start(fileName);<br />
            }<br />
            catch { }<br />
        }<br />
[/csharp]</p>
<p>Now it is time to run our program. You will see the output as follows.</p>
<div id="attachment_9071" style="width: 310px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/08/Excel_Bar_Chart.png"><img decoding="async" aria-describedby="caption-attachment-9071" src="http://sibeeshpassion.com/wp-content/uploads/2015/08/Excel_Bar_Chart.png" alt="Excel Bar Chart" width="300" height="300" class="size-full wp-image-9071" srcset="/wp-content/uploads/2015/08/Excel_Bar_Chart.png 300w, /wp-content/uploads/2015/08/Excel_Bar_Chart-150x150.png 150w, /wp-content/uploads/2015/08/Excel_Bar_Chart-130x130.png 130w" sizes="(max-width: 300px) 100vw, 300px" /></a><p id="caption-attachment-9071" class="wp-caption-text">Excel Bar Chart</p></div>
<div id="attachment_9081" style="width: 669px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/08/Excel_Bar_Chart_Output.png"><img decoding="async" aria-describedby="caption-attachment-9081" src="http://sibeeshpassion.com/wp-content/uploads/2015/08/Excel_Bar_Chart_Output.png" alt="Excel Bar Chart " width="659" height="458" class="size-full wp-image-9081" srcset="/wp-content/uploads/2015/08/Excel_Bar_Chart_Output.png 659w, /wp-content/uploads/2015/08/Excel_Bar_Chart_Output-300x208.png 300w, /wp-content/uploads/2015/08/Excel_Bar_Chart_Output-160x110.png 160w, /wp-content/uploads/2015/08/Excel_Bar_Chart_Output-400x278.png 400w" sizes="(max-width: 659px) 100vw, 659px" /></a><p id="caption-attachment-9081" class="wp-caption-text">Excel Bar Chart</p></div>
<p>As you can see it is very easy to give styles and border to our chart.</p>
<p>[csharp]<br />
//Style<br />
            sheet.Range[&quot;A1:C1&quot;].Style.Font.IsBold = true;<br />
            sheet.Range[&quot;A2:C2&quot;].Style.KnownColor = ExcelColors.LightYellow;<br />
            sheet.Range[&quot;A3:C3&quot;].Style.KnownColor = ExcelColors.LightGreen1;<br />
            sheet.Range[&quot;A4:C4&quot;].Style.KnownColor = ExcelColors.LightOrange;<br />
            sheet.Range[&quot;A5:C5&quot;].Style.KnownColor = ExcelColors.LightTurquoise;<br />
            //Border<br />
            sheet.Range[&quot;A1:C5&quot;].Style.Borders[BordersLineType.EdgeTop].Color = Color.FromArgb(0, 0, 128);<br />
            sheet.Range[&quot;A1:C5&quot;].Style.Borders[BordersLineType.EdgeTop].LineStyle = LineStyleType.Thin;<br />
            sheet.Range[&quot;A1:C5&quot;].Style.Borders[BordersLineType.EdgeBottom].Color = Color.FromArgb(0, 0, 128);<br />
            sheet.Range[&quot;A1:C5&quot;].Style.Borders[BordersLineType.EdgeBottom].LineStyle = LineStyleType.Thin;<br />
            sheet.Range[&quot;A1:C5&quot;].Style.Borders[BordersLineType.EdgeLeft].Color = Color.FromArgb(0, 0, 128);<br />
            sheet.Range[&quot;A1:C5&quot;].Style.Borders[BordersLineType.EdgeLeft].LineStyle = LineStyleType.Thin;<br />
            sheet.Range[&quot;A1:C5&quot;].Style.Borders[BordersLineType.EdgeRight].Color = Color.FromArgb(0, 0, 128);<br />
            sheet.Range[&quot;A1:C5&quot;].Style.Borders[BordersLineType.EdgeRight].LineStyle = LineStyleType.Thin;<br />
            sheet.Range[&quot;B2:C5&quot;].Style.NumberFormat = &quot;\&quot;$\&quot;#,##0&quot;;<br />
[/csharp]</p>
<p>Like this we can crate Line Chart, Radar Chart and many more. Please try those too. Now we will see How to Save Excel Charts as Images.</p>
<p><strong>How to Save Excel Charts as Images</strong></p>
<p>Create another button and write the preceding codes in button click.</p>
<p>[csharp]<br />
private void button2_Click(object sender, EventArgs e)<br />
        {<br />
            Workbook workbook = new Workbook();<br />
            workbook.LoadFromFile(&quot;D:\\Sample.xlsx&quot;, ExcelVersion.Version2010);<br />
            Worksheet sheet = workbook.Worksheets[0];<br />
            Image[] imgs = workbook.SaveChartAsImage(sheet);<br />
            for (int i = 0; i &lt; imgs.Length; i++)<br />
            {<br />
                imgs[i].Save(string.Format(&quot;img-{0}.png&quot;, i), System.Drawing.Imaging.ImageFormat.Png);<br />
            }</p>
<p>        }<br />
[/csharp]</p>
<p>Here we are taking a file called Sample.xlsx and loop through the charts inside the file and save those as images with few lines codes. Sounds good right?</p>
<p><strong>VB.Net Code</strong><br />
[vb]<br />
Dim workbook As New Workbook()<br />
workbook.LoadFromFile(&quot;D:\\Sample.xlsx&quot;, ExcelVersion.Version2010)<br />
Dim sheet As Worksheet = workbook.Worksheets(0)<br />
Dim imgs As Image() = workbook.SaveChartAsImage(sheet)<br />
For i As Integer = 0 To imgs.Length &#8211; 1<br />
    imgs(i).Save(String.Format(&quot;img-{0}.png&quot;, i), ImageFormat.Png)<br />
Next<br />
[/vb]</p>
<p><strong>Conclusion</strong></p>
<p>I hope you liked this article. Please share me your valuable suggestions and feedback.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sibeeshpassion.com/working-with-charts-using-spire-xls/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Using Spire.XLS</title>
		<link>https://sibeeshpassion.com/using-spire-xls/</link>
					<comments>https://sibeeshpassion.com/using-spire-xls/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Sun, 12 Jul 2015 08:34:08 +0000</pubDate>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Products]]></category>
		<category><![CDATA[Spire.XLS]]></category>
		<category><![CDATA[Convert Excel to PDF]]></category>
		<category><![CDATA[Convert Excel to PDF in C#]]></category>
		<category><![CDATA[Convert Excel to PDF in CSharp]]></category>
		<category><![CDATA[Excel to HTML]]></category>
		<category><![CDATA[Spire.Office]]></category>
		<category><![CDATA[Spire.XLs]]></category>
		<category><![CDATA[Using Spire.XLS]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=6731</guid>

					<description><![CDATA[[toc] Introduction Hi I hope you all are fine. Today we are going to see a new product Spire.XLS which helps us to create, manipulate, convert EXCEL file to other formats and many more. This product has been introduced by the company E-Iceblue. I hope you have read my article of Spire.Doc. If you have not read it, I recommend you to read it here: Using Spire.Doc Download source code Using Spire XLS With Visual Studio Background Always, managing excel files through code is a tough job for me. If you are also thinking the same, I h3ly recommend this [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>[toc]</p>
<h3>Introduction</h3>
<p>Hi I hope you all are fine. Today we are going to see a new product <em>Spire.XLS</em> which helps us to create, manipulate, convert EXCEL file to other formats and many more. This product has been introduced by the company <a href="http://www.e-iceblue.com/" target="_blank" rel="noopener">E-Iceblue</a>. I hope you have read my article of <em>Spire.Doc</em>. If you have not read it, I recommend you to read it here: <a href="http://sibeeshpassion.com/using-spire-doc-introduction/" target="_blank" rel="noopener">Using Spire.Doc</a></p>
<h3>Download source code </h3>
<li><a href="https://code.msdn.microsoft.com/Using-SpireXLS-With-Visual-00c1d812" target="_blank" rel="noopener">Using Spire XLS With Visual Studio</a></li>
<h3>Background</h3>
<p>Always, managing excel files through code is a tough job for me. If you are also thinking the same, I h3ly recommend this product Spire.XLX from E-Iceblue. It made the task easier than ever. In this article I will show you the demo for converting the Excel files to other formats. I hope you will like it.</p>
<h3>Download the files</h3>
<p>You can always the needed files from here: <a href="http://www.e-iceblue.com/Download/download-excel-for-net-now.html" target="_blank" rel="noopener">Download Spire.XLS</a></p>
<h3>Install Spire.XLS</h3>
<p>I am using evaluation version with one month temporary license. There are free versions also available for spire.xls with some limitation. You can try that. Now click on the exe file after you extract the downloaded file. The installation will get started then.</p>
<p><img decoding="async" src="http://sibeeshpassion.com/content/images/InstallSpireXls.png" width="513" height="405" class="alignnone size-full" /></p>
<p>So Shall we start?</p>
<p>Once you Installed, you are ready to go. We will start with a “Simple Windows Form ” Application. Before getting started, Please install Spire.XLs and Visual studio 2008 or above. I am using Visual Studio 2015 RC. I hope everything set ?</p>
<p>Open your Visual Studio, click on New->Project->Select Visual C# (if you are good in C# or select Visual Basic) Project->Windows->Windows forms application->Name your project(I am naming it as Using SpireXLs)</p>
<p><img decoding="async" src="http://sibeeshpassion.com/content/images/UsingSpireXLS1.png" alt="Using Spire XLS" /></p>
<p>Now create a group box and a button in your form and name them :). Later, click on the button. </p>
<p><img decoding="async" src="http://sibeeshpassion.com/content/images/UsingSpireXLS2.png" alt="Using Spire XLS" /></p>
<p>Now right click on your project and click add reference, in the browse tab find out the folder in which you have installed spire xls. Usually it will be in the C:\Program Files\e-iceblue\Spire.Xls. Now just find your framework version from BIN folder and add Spire.xls.dll</p>
<p><img decoding="async" src="http://sibeeshpassion.com/content/images/UsingSpireXLS3.png" alt="Using Spire XLS" /></p>
<p><img decoding="async" src="http://sibeeshpassion.com/content/images/AddingSpireXLSReference.png" alt="Using Spire XLS" /></p>
<p>Now we have added reference too. So shall we start coding ?</p>
<h3>Using the code</h3>
<p>To start with coding you need to add the needed namespaces as follows.</p>
<p>[csharp]<br />
using Spire.Xls;<br />
using Spire.Pdf;<br />
using Spire.Xls.Converter;<br />
[/csharp]</p>
<p>In the button click event you need to add the following lines codes.</p>
<h4>C# Code</h4>
<p>[csharp]<br />
private void button1_Click(object sender, EventArgs e)<br />
        {<br />
             // load Excel file<br />
           Workbook workbook = new Workbook();<br />
           workbook.LoadFromFile(&quot;D:\\MyExcel.xlsx&quot;);<br />
           // Set PDF template<br />
           PdfDocument pdfDocument = new PdfDocument();<br />
           pdfDocument.PageSettings.Orientation = PdfPageOrientation.Landscape;<br />
           pdfDocument.PageSettings.Width = 970;<br />
           pdfDocument.PageSettings.Height = 850;<br />
           //Convert Excel to PDF using the template above<br />
           PdfConverter pdfConverter = new PdfConverter(workbook);<br />
           PdfConverterSettings settings = new PdfConverterSettings();<br />
           settings.TemplateDocument = pdfDocument;<br />
           pdfDocument = pdfConverter.Convert(settings);<br />
           // Save and preview PDF<br />
           pdfDocument.SaveToFile(&quot;MyPDF.pdf&quot;);<br />
           System.Diagnostics.Process.Start(&quot;MyPDF.pdf&quot;);</p>
<p>        }<br />
[/csharp]</p>
<h4>VB.NET Code</h4>
<p>[csharp]<br />
&#8216;load Excel file<br />
            Dim workbook As New Workbook()<br />
            workbook.LoadFromFile(&quot;D:\MyExcel.xlsx&quot;)<br />
            &#8216; Set PDF template<br />
            Dim pdfDocument As New PdfDocument()<br />
            pdfDocument.PageSettings.Orientation = PdfPageOrientation.Landscape<br />
            pdfDocument.PageSettings.Width = 970<br />
            pdfDocument.PageSettings.Height = 850<br />
            &#8216;Convert Excel to PDF using the template above<br />
            Dim pdfConverter As New PdfConverter(workbook)<br />
            Dim settings As New PdfConverterSettings()<br />
            settings.TemplateDocument = pdfDocument<br />
            pdfDocument = pdfConverter.Convert(settings)<br />
            &#8216; Save and preview PDF<br />
            pdfDocument.SaveToFile(&quot;MyPdf.pdf&quot;)<br />
            System.Diagnostics.Process.Start(&quot;MyPdf.pdf&quot;)<br />
[/csharp]</p>
<p>In the above lines code, we are loading an excel file MyExcel.xlsx from my drive. The following is the content of our excel file.</p>
<p><img decoding="async" src="http://sibeeshpassion.com/content/images/SpireXLSSampleExcelFile.png" alt="Using Spire XLS" /></p>
<p>Now if you run your project and click our button, you will get a pdf file as follows.</p>
<p><img decoding="async" src="http://sibeeshpassion.com/content/images/SpireXLSPDFConvertOutput.png" alt="Using Spire XLS" /></p>
<p>Cool!. Very simple right? Now we will go to other conversions as well.</p>
<h3>Excel to HTML</h3>
<p>To convert our excel file to HTML, you need to create a button in our form and paste the following codes to the button click event.</p>
<h4>C# Code</h4>
<p>[csharp]<br />
private void button2_Click(object sender, EventArgs e)<br />
        {<br />
            //load Excel file<br />
            Workbook workbook = new Workbook();<br />
            workbook.LoadFromFile(&quot;D:\\MyExcel.xlsx&quot;);<br />
            //convert Excel to HTML<br />
            Worksheet sheet = workbook.Worksheets[0];<br />
            sheet.SaveToHtml(&quot;MyHTML.html&quot;);<br />
            //Preview HTML<br />
            System.Diagnostics.Process.Start(&quot;MyHTML.html&quot;);</p>
<p>        }<br />
[/csharp]</p>
<h4>VB.NET Code</h4>
<p>[csharp]<br />
 Private Shared Sub Main(args As String())<br />
            &#8216;load Excel file<br />
            Dim workbook As New Workbook()<br />
            workbook.LoadFromFile(&quot;D:\\MyExcel.xlsx&quot;)<br />
            &#8216;convert Excel to HTML<br />
            Dim sheet As Worksheet = workbook.Worksheets(0)<br />
            sheet.SaveToHtml(&quot;MyHTML.html&quot;)<br />
            &#8216;Preview HTML<br />
            System.Diagnostics.Process.Start(&quot;MyHTML.html&quot;)<br />
        End Sub<br />
[/csharp]</p>
<p>Now if you run the code, you can see an html file as follows.</p>
<p><img decoding="async" src="http://sibeeshpassion.com/content/images/SpireXLsConvertHTMLPutput.png" alt="Using Spire XLS" /></p>
<h3>Excel To Image</h3>
<p>To convert our excel file to image, you need to create a button in our form and paste the following codes to the button click event.</p>
<h4>C# Code</h4>
<p>[csharp]<br />
private void button3_Click(object sender, EventArgs e)<br />
        {<br />
            Workbook workbook = new Workbook();<br />
            workbook.LoadFromFile(&quot;D:\\MyExcel.xlsx&quot;);<br />
            Worksheet sheet = workbook.Worksheets[0];<br />
            sheet.SaveToImage(&quot;MyImage.jpg&quot;);</p>
<p>        }<br />
[/csharp]</p>
<h4>VB.NET Code</h4>
<p>[csharp]<br />
  Shared Sub Main(ByVal args() As String)<br />
                     Dim workbook As New Workbook()<br />
                     workbook.LoadFromFile(&quot;D:\\MyExcel.xlsx&quot;)<br />
                     Dim sheet As Worksheet = workbook.Worksheets(0)<br />
                     sheet.SaveToImage(&quot;MyImage.jpg&quot;)<br />
  End Sub<br />
[/csharp]</p>
<p>Now if you run the code, you can see an Image as follows.</p>
<p><img decoding="async" src="http://sibeeshpassion.com/content/images/SpireXLSConvertExcelToImagesOutput1.png" alt="Using Spire XLS"/></p>
<p><img decoding="async" src="http://sibeeshpassion.com/content/images/SpireXLSConvertExcelToImagesOutput2.png" alt="Using Spire XLS"/></p>
<h3>Excel to CSV</h3>
<p>To convert our excel file to image, you need to create a button in our form and paste the following codes to the button click event.</p>
<h4>C# Code</h4>
<p>[csharp]<br />
private void button3_Click(object sender, EventArgs e)<br />
        {<br />
            Workbook workbook = new Workbook();<br />
            workbook.LoadFromFile(&quot;D:\\MyExcel.xlsx&quot;);<br />
            Worksheet sheet = workbook.Worksheets[0];<br />
            sheet.SaveToFile(&quot;MyCSV.csv&quot;, &quot;,&quot;, Encoding.UTF8);</p>
<p>        }<br />
[/csharp]</p>
<h4>VB.NET Code</h4>
<p>[csharp]<br />
  Shared Sub Main(ByVal args() As String)<br />
                     Dim workbook As New Workbook()<br />
                     workbook.LoadFromFile(&quot;D:\\MyExcel.xlsx&quot;)<br />
                     Dim sheet As Worksheet = workbook.Worksheets(0)<br />
                     sheet.SaveToFile(&quot;MyCSV.csv&quot;, &quot;,&quot;, Encoding.UTF8)</p>
<p>  End Sub<br />
[/csharp]</p>
<p>Now if you run the code, you can see a CSV file as follows.</p>
<p><img decoding="async" src="http://sibeeshpassion.com/content/images/SpireXLSConvertExcelToCSVOutput.png" alt="Using Spire XLS"/></p>
<p><em>Please be noted that, you can convert your excel to any other file format, there are plenty of options available. Please try that too. I have given only three options which I use always.</em></p>
<h3>Conclusion</h3>
<p>Did I miss anything that you may think which is needed? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.</p>
<h3>Your turn. What do you think?</h3>
<p>A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sibeeshpassion.com/using-spire-xls/feed/</wfw:commentRss>
			<slash:comments>9</slash:comments>
		
		
			</item>
	</channel>
</rss>
