Friday, 09 September 2011 03:37

Excel DropDownList Sample

The sample demonstrates how to provide a dropdownlist for valid data

Published in Validation
Wednesday, 07 September 2011 06:00

Excel Read Data With Formulas

The sample demonstrates how to read data with fomulas

Published in Formulas
Wednesday, 07 September 2011 05:39

Calculate With Formula

The sample demonstrates how to calculate formulas

Published in Formulas
Wednesday, 07 September 2011 04:56

Excel Data Export With Formulas

The sample demonstrates how to export data to datatable with calculating formulas

Published in Formulas
Tuesday, 06 September 2011 08:03

SparkLine Chart

The sample demonstrates how to insert SparkLine into an excel workbook.

Published in Charts
Tuesday, 06 September 2011 06:39

Excel Cell Names

The sample demonstrates how to define named cell references or ranges in excel workbook.

Download MiscDataTable.xls

Published in Formulas
Tuesday, 30 August 2011 09:21

XLS Report Silverlight

The sample demonstrates how to work with MarkerDesign in Silverlight via Spire.XLS.

Download template xls file.

Download data table file.

Download merged result file.

Published in Silverlight
Monday, 25 July 2011 09:12

XLS to PDF in C#, VB.NET

The sample demonstrates how to convert Excel workbook to PDF file via Spire.XLS.

Get XLS-to-PDF.pdf.

Published in Misc
Monday, 24 January 2011 09:52

Generate Excel Column Chart in C#, VB.NET

Excel Charts uses graphics to present data information to enable users to analyze data more intuitively. According to details of data information, users need to choose the most appropriate chart type. For example, column chart is suitable for comparison between data, while pie chart is often used to show percentage of each item among all.

Spire.XLS for .NET, a stand-alone Excel operation component designed for .NET developers, allows users to generate Excel chart, and this guide will show you how to generate excel column chart with C#, VB.NET via Spire.XLS for .NET. Users can use sheet.Charts.Add(ExcelChartType) method to add chart in Excel. Then, assign value for DataRange property of Chart class to fill information in chart area. Next, set position, chart title, axes, legend and format them for chart to make the chart be more completed and wonderful.

The following screenshot shows the result of Excel column chart generation.

Generate Excel Column Chart

Download and install Spire.XLS for .NET. Use the following code to generate Excel column chart.

[C#]
using System.Drawing;
using Spire.Xls;

namespace XLSTest
{
    class Program
    {
        static void Main(string[] args)
        {
            //Load Workbook
            Workbook workbook = new Workbook();
            workbook.LoadFromFile(@"E:\Work\Documents\ExcelFiles\PartSalesInfo.xlsx");       
            Worksheet sheet = workbook.Worksheets[0];

            //Add Chart and Set Chart Data Range
            Chart chart = sheet.Charts.Add(ExcelChartType.ColumnClustered);
            chart.DataRange = sheet.Range["D1:E17"];
            chart.SeriesDataFromRange = false;

            //Chart Position
            chart.LeftColumn = 1;
            chart.TopRow = 19;
            chart.RightColumn = 8;
            chart.BottomRow = 33;

            //Chart Border
            chart.ChartArea.Border.Weight = ChartLineWeightType.Medium;
            chart.ChartArea.Border.Color = Color.SandyBrown;

            //Chart Title
            chart.ChartTitle = "Parts Sales Info";
            chart.ChartTitleArea.Font.FontName = "Calibri";
            chart.ChartTitleArea.Font.Size = 13;
            chart.ChartTitleArea.Font.IsBold = true;

            //Chart Axes
            chart.PrimaryCategoryAxis.Title = "Parts";
            chart.PrimaryCategoryAxis.Font.Color = Color.Blue;

            chart.PrimaryValueAxis.Title = "Amounts";
            chart.PrimaryValueAxis.HasMajorGridLines = false;
            chart.PrimaryValueAxis.MaxValue = 350;
            chart.PrimaryValueAxis.TitleArea.TextRotationAngle = 90;

            //Chart Legend
            chart.Legend.Position = LegendPositionType.Right;

            //Save and Launch
            workbook.SaveToFile("ExcelColumnChart.xlsx",ExcelVersion.Version2010);
            System.Diagnostics.Process.Start("ExcelColumnChart.xlsx");

        }
    }
}
[VB.NET]
Imports System.Drawing
Imports Spire.Xls

Namespace XLSTest
    Friend Class Program
        Shared Sub Main(ByVal args() As String)
            'Load Workbook
            Dim workbook As New Workbook()
            workbook.LoadFromFile("E:\Work\Documents\ExcelFiles\PartSalesInfo.xlsx")
            Dim sheet As Worksheet = workbook.Worksheets(0)

            'Add Chart and Set Chart Data Range
            Dim chart As Chart = sheet.Charts.Add(ExcelChartType.ColumnClustered)
            chart.DataRange = sheet.Range("D1:E17")
            chart.SeriesDataFromRange = False

            'Chart Position
            chart.LeftColumn = 1
            chart.TopRow = 19
            chart.RightColumn = 8
            chart.BottomRow = 33

            'Chart Border
            chart.ChartArea.Border.Weight = ChartLineWeightType.Medium
            chart.ChartArea.Border.Color = Color.SandyBrown

            'Chart Title
            chart.ChartTitle = "Parts Sales Info"
            chart.ChartTitleArea.Font.FontName = "Calibri"
            chart.ChartTitleArea.Font.Size = 13
            chart.ChartTitleArea.Font.IsBold = True

            'Chart Axes
            chart.PrimaryCategoryAxis.Title = "Parts"
            chart.PrimaryCategoryAxis.Font.Color = Color.Blue

            chart.PrimaryValueAxis.Title = "Amounts"
            chart.PrimaryValueAxis.HasMajorGridLines = False
            chart.PrimaryValueAxis.MaxValue = 350
            chart.PrimaryValueAxis.TitleArea.TextRotationAngle = 90

            'Chart Legend
            chart.Legend.Position = LegendPositionType.Right

            'Save and Launch
            workbook.SaveToFile("ExcelColumnChart.xlsx", ExcelVersion.Version2010)
            System.Diagnostics.Process.Start("ExcelColumnChart.xlsx")

        End Sub
    End Class
End Namespace
Published in Chart
Thursday, 20 January 2011 10:33

Insert Image in Excel in C#, VB.NET

Users are allowed to insert image in Excel files. With image, the appearance of Excel file will be more beautiful. Besides decorating, some images are related to data information in Excel. For example, the image will be a chart. These images can make readers learn data information more clearly. This guide will show an easy method to insert image in Excel with C#, VB.NET

Spire.XLS for .NET, a professional component to operating Excel files, enables users to insert image in Excel by using C# and VB.NET. This guide focuses on how to easily insert image in Excel by using Spire.XLS for .NET.  Developers can use sheet.Pictures.Add(int toprow, int leftcolumn, filename string) method to insert image in Excel directly. Below demonstrates an Excel with an image of flower.

Insert Excel Image

Download and install Spire.XLS for .NET and then use the following code to insert image.

[C#]
using Spire.Xls;

namespace InsertImage
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create Workbook
            Workbook workbook = new Workbook();
            Worksheet sheet = workbook.Worksheets[0];

            //Insert Image
            sheet.Pictures.Add(1, 1, @"E:\work\sample.jpg");

            //Save and Launch
            workbook.SaveToFile("ExcelImage.xlsx", ExcelVersion.Version2010);
            System.Diagnostics.Process.Start("ExcelImage.xlsx");
        }
    }
}
[VB.NET]
Imports Spire.Xls

Namespace InsertImage
    Friend Class Program
        Shared Sub Main(ByVal args() As String)
            'Create Workbook
            Dim workbook As New Workbook()
            Dim sheet As Worksheet = workbook.Worksheets(0)

            'Insert Image
            sheet.Pictures.Add(1, 1, "E:\work\sample.jpg")

            'Save and Launch
            workbook.SaveToFile("ExcelImage.xlsx", ExcelVersion.Version2010)
            System.Diagnostics.Process.Start("ExcelImage.xlsx")
        End Sub
    End Class
End Namespace
Published in Image
Page 1 of 2