Close





 
Monday, 08 August 2011 03:47

How to Use C#/VB.NET to Add Excel Borders

How to Use C#/VB.NET to Add Excel Borders

Why We Add Excel Borders?

"Borders" here we called is a tool which built in Microsoft Excel program. Users can access predefined styles of border and add excel borders around 2 or more cells. It's very easy to create your own customized borders by using borders tool. Users can distinguish different kind of information data by adding different styles of borders which will reduce or eliminate many human operation errors.

How to Add Excel Borders in Microsoft Excel?

It's very simple to use Microsoft Excel add excel borders. First, launch your MS Excel and choose the excel file you want to work with and open it. Find out the area in the spreadsheet that you want to have borders. Drag your mouse over the cells in the area and righ click to open options window. Now, select Format Cells ->Border and several options will appear on another new window. In the "Style" box, you can choose the border design as you like by cliking the line type. You can add different borders in different areas of the spreadsheet to see what suits your need. From the "Color" drop down menu, you can select any color you want to change the color of your borders.

How to Use Spire.XLS for .NET to Add Excel Borders?

Here, we suppose we have written text in a cell of an Excel document. Now, we can add borders simply by setting the color and the line style with the sheet.Range["A1"].Borders.Color and sheet.Range["A1"].Borders.LineStyle methods. Something must be paid attention, sheet.Range["A1"].Borders method in Spire.XLS contains six borders:Four borders and two diagonals. You can delete the two diagonals by setting the sheet.Range["A1"].Borders[BordersLineType.DiagonalDown].LineStyle and sheet.Range["A1"].Borders[BordersLineType.DiagonalUp].LineStyle none.
Code of C# for adding excel borders:
[C#]
using System.Drawing;
using Spire.Xls;

namespace ExtractText
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a new workbook.
            Workbook workbook = new Workbook();
            Worksheet sheet = workbook.Worksheets[0];
            
            //Write text in B2.
            sheet.Range["B2"].Text = "Home page";
            
            //Set the color of the six borders.
            sheet.Range["B2"].Borders.Color = Color.Green;
            
            //Set the line style of the borders. 
            sheet.Range["B2"].Borders.LineStyle = LineStyleType.Thick;
            
            //Delete the diagonalDown border.
            sheet.Range["B2"].Borders[BordersLineType.DiagonalDown].LineStyle = LineStyleType.None;
            
            //Delete the DiagonalUp border.
            sheet.Range["B2"].Borders[BordersLineType.DiagonalUp].LineStyle = LineStyleType.None;
            sheet.AutoFitColumn(2);
            
            //Save the file.
            workbook.SaveToFile("Sample.xls");
            
            //Launch the file.
            System.Diagnostics.Process.Start("Sample.xls");
        }
    }
}
          
Code of VB.NET for adding excel borders:
[Visual Basic]
Imports Microsoft.VisualBasic
Imports System.Drawing
Imports Spire.Xls

Module Module1

    Sub Main()
        'Create a new workbook.
        Dim workbook As Workbook = New Workbook()
        Dim sheet As Worksheet = workbook.Worksheets(0)
        
        'Write text in B2.
        sheet.Range("B2").Text = "Home page"
        
        'Set the color of the six borders.
        sheet.Range("B2").Borders.Color = Color.Green
        
        'Set the line style of the borders. 
        sheet.Range("B2").Borders.LineStyle = LineStyleType.Thick
        
        'Delete the diagonalDown border.
        sheet.Range("B2").Borders(BordersLineType.DiagonalDown).LineStyle = LineStyleType.None
        
        'Delete the DiagonalUp border.
        sheet.Range("B2").Borders(BordersLineType.DiagonalUp).LineStyle = LineStyleType.None
        sheet.AutoFitColumn(2)
        
        'Save the file.
        workbook.SaveToFile("Sample.xls")
        
        'Launch the file.
        System.Diagnostics.Process.Start("Sample.xls")
    End Sub
End Module
          
The program will show you the sample after you excute the above C#/VB.NET source codes.

More about Spire.XLS
Download Spire.XLS
Purchase Spire.XLS

Published in Program Guide
Monday, 25 July 2011 09:12

XLS to PDF for 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

How to Export DataTable to Excel through DataGridView

Export DataTable to Excel can be very easy through Spire.DataExport (or Spire.Office). Furthermore, Spire.DataExport enables user to Export data to Excel through DataGridView. Through DataGridView users can preview and modify data information before exporting.

 

Download Spire.DataExport (or Spire.Office) with .NET Framework together. Only 2 Simple steps you can finish the whole datatable to Excel exporting process.

 

Step 1, Load Data Information

In this step, Spire.DataExport will help you load Data information from your datatable. After you put in your data source and SQL command, you can preview and modify data information in DataGridView area.

 

[C#]
	
        private void btnLoad_Click(object sender, EventArgs e)
        {
            using(OleDbConnection oleDbConnection = new OleDbConnection())
            {
                oleDbConnection.ConnectionString = this.textBox1.Text;
                OleDbCommand oleDbCommand = new OleDbCommand();
                oleDbCommand.CommandText = this.textBox2.Text;
                oleDbCommand.Connection = oleDbConnection;
                using(OleDbDataAdapter da = new OleDbDataAdapter(oleDbCommand))
                {
                    DataTable dt = new DataTable();
                    da.Fill(dt);
                    dataGridView1.DataSource = dt;
                }
            }
        } 

   

Effect Screenshot

Step 2, Set Export into Excel

Spire.DataExport allows user to export data into most popular file formats including MS Excel, MS Word, HTML, PDF, XML, CSV, DBF, DIF, etc. Now, in this step you should give an order to Export Data into Excel file format. Spire.DataExport will create a new MS Excel Worksheet for storing Data which exported out. You can rename the excel file in this step either.

 

[C#]
        private void btnRun_Click(object sender, EventArgs e)
        {
            Spire.DataExport.XLS.CellExport cellExport = new Spire.DataExport.XLS.CellExport();
            Spire.DataExport.XLS.WorkSheet worksheet1 = new Spire.DataExport.XLS.WorkSheet();
            worksheet1.DataSource = Spire.DataExport.Common.ExportSource.DataTable;
            worksheet1.DataTable = this.dataGridView1.DataSource as DataTable;
            worksheet1.StartDataCol = ((System.Byte)(0));
            cellExport.Sheets.Add(worksheet1);
            cellExport.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView; 
            cellExport.SaveToFile("20110223.xls");
        }
       
          


Effect Screenshot

 

More about Spire.DataExport

Download Spire.DataExport

Purchase Spire.DataExport

Published in Program Guide
Monday, 24 January 2011 09:49

Save Excel Document with C# and VB.NET

In general, we need to create a new Excel workbook, initialize worksheet and then edit it, finally save it to a file. This section will show you how to saveas it via Spire.XLS for C#/.NET.

Workbook Save in MS

In Microsoft Office, we can save the file as different formats. You can save it as XML spreadsheet, XML data, single flie web page, web page and template. When saving it, you may specify the file name. Furthermore, you may come aross some problems. Remember that after you install MS Office, in VB.NET excel 2007 you should add the COM reference. In the solution explorer, choose COM TAB, and then reference Microsoft Word 11.0 Object Library. Then add the namespace: using System.Reflection, and reference C# Microsoft.Office.Interop.Excel.

C# excel workbook.saveas via Spire.XLS

Spire.XLS presents you an easy way to saveas an Excel document. When you finish writing the Excel workbook, you may want to save it. You can use workbook.SaveAsXml method to save the Excel workbook as XML format. When you use C# excel workbook.saveas, you may set the name of your file.
The following code is about C# excel workbook.saveas:
[C#]
using Spire.Xls;

namespace Saveas
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a new workbook
            Workbook workbook = new Workbook();

            //Initialize worksheet
            Worksheet sheet = workbook.Worksheets[0];

            //Append text
            sheet.Range["A1"].Text = "demo";
           
            //Save it as XML file
            workbook.SaveAsXml("Sample.xml");

            //Launch the file
            System.Diagnostics.Process.Start("Sample.xml");
        }
    }
}
          
[Visual Basic]
Imports Spire.Xls

Module Module1

    Sub Main()
        'Create a new workbook
        Dim workbook As New Workbook()

        'Initialize worksheet
        Dim sheet As Worksheet = workbook.Worksheets(0)

        'Append text
        sheet.Range("A1").Text = "demo"

        'Save it as XML file.
        workbook.SaveAsXml("Sample.xml")

        'Launching the MS Word file.
        System.Diagnostics.Process.Start("Sample.xml")

    End Sub
End Module
          
Published in Program Guide
Monday, 24 January 2011 09:43

How to Add a Formula for Excel

Introduction

In an Excel Worksheet, we may import a great deal of data. Sometimes, we need to calculate the data to get other numbers we need. Formula is the mail tool to calculate data.
There are various formulas included in Excel. Actually, formulas are equations and each one starts with an equal sign. We can use a formula to calculate values for a column list. A formula contains four parts: functions, column references, operators and constants.

How to Add Formula for Excel in MS

There are different methods to add a formula for Excel including different parts. This example is about formulas containing functions. The example is about how to average all numbers in the range from A1 to B4.
First, click the cell where we want to add the formula. Then, click Insert Function on the formula bar. Third, select the function we want to use. We can search the function or browse form the categories. Next, enter the arguments. Click Collapse Dialog to hide the dialog box to enter cell references as an argument. Press Expand Dialog after selecting the cells on the worksheet. Finally, Press Enter when we complete the formula.

How to Add Formula for Excel with Spire.XLS

Spire.XLS presents you an easiest way to add formula for Excel. We will give you a demo with many kinds of formulas written in the worksheet. The formula can be string, bool value, calculation, sheet area reference, time and so on. Here, we reference a variable "currentRow" to control rows of all kinds of formulas. You may add formula text with the property of sheet.Range[++currentRow, 1].Text, and calculate the formula with the property of sheet.Range[currentRow, 2].Formula.
The following code shows how to add a formula for Excel with C#/VB.NET:
[C#]
using Spire.Xls;

namespace Formula
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a new workbook
            Workbook workbook = new Workbook();

            //Initialize worksheet
            Worksheet sheet = workbook.Worksheets[0];

            //initialize currentRow
            int currentRow = 3;
            string currentFormula = string.Empty;
            
            //test data
            sheet.Range[currentRow, 2].NumberValue = 7.3;
            sheet.Range[currentRow, 3].NumberValue = 5; ;
            sheet.Range[currentRow, 4].NumberValue = 8.2;
            sheet.Range[currentRow, 5].NumberValue = 4;
            sheet.Range[currentRow, 6].NumberValue = 3;
            sheet.Range[currentRow, 7].NumberValue = 11.3;
            
            //string.
            currentFormula = "=\"hello\"";
            sheet.Range[++currentRow, 1].Text = "=\"hello\"";
            sheet.Range[currentRow, 2].Formula = currentFormula;

            //bool.
            currentFormula = "=false";
            sheet.Range[++currentRow, 1].Text = currentFormula;
            sheet.Range[currentRow, 2].Formula = currentFormula;

            //calculation
            currentFormula = "=33*3/4-2+10";
            sheet.Range[++currentRow, 1].Text = currentFormula;
            sheet.Range[currentRow, 2].Formula = currentFormula;

            //sheet area reference
            currentFormula = "=AVERAGE(Sheet1!$D$3:G$3)";
            sheet.Range[++currentRow, 1].Text = currentFormula;
            sheet.Range[currentRow, 2].Formula = currentFormula;

            //time
            currentFormula = "=NOW()";
            sheet.Range[++currentRow, 1].Text = currentFormula;
            sheet.Range[currentRow, 2].Formula = currentFormula;
            sheet.Range[currentRow, 2].Style.NumberFormat = "yyyy-MM-DD";

            //Save the file
            workbook.SaveToFile("Sample.xls");

            //Launch the file
            System.Diagnostics.Process.Start("Sample.xls");
        }
    }
}
          
[Visual Basic]
Imports Spire.Xls

Module Module1

    Sub Main()
        'Create a new workbook
        Dim workbook As New Workbook()

        'Initialize worksheet
        Dim sheet As Worksheet = workbook.Worksheets(0)

        'initialize currentRow
        Dim currentRow As Integer = 3
        Dim currentFormula As String = String.Empty

        'test data
        sheet.Range(currentRow, 2).NumberValue = 7.3
        sheet.Range(currentRow, 3).NumberValue = 5


        sheet.Range(currentRow, 4).NumberValue = 8.2
        sheet.Range(currentRow, 5).NumberValue = 4
        sheet.Range(currentRow, 6).NumberValue = 3
        sheet.Range(currentRow, 7).NumberValue = 11.3

        'string.
        currentFormula = "=""hello"""
        sheet.Range(System.Threading.Interlocked.Increment(currentRow), 1).Text = "=""hello"""
        sheet.Range(currentRow, 2).Formula = currentFormula

        'bool.
        currentFormula = "=false"
        sheet.Range(System.Threading.Interlocked.Increment(currentRow), 1).Text = currentFormula
        sheet.Range(currentRow, 2).Formula = currentFormula

        'calculation
        currentFormula = "=33*3/4-2+10"
        sheet.Range(System.Threading.Interlocked.Increment(currentRow), 1).Text = currentFormula
        sheet.Range(currentRow, 2).Formula = currentFormula

        'sheet area reference
        currentFormula = "=AVERAGE(Sheet1!$D$3:G$3)"
        sheet.Range(System.Threading.Interlocked.Increment(currentRow), 1).Text = currentFormula
        sheet.Range(currentRow, 2).Formula = currentFormula

        'time
        currentFormula = "=NOW()"
        sheet.Range(System.Threading.Interlocked.Increment(currentRow), 1).Text = currentFormula
        sheet.Range(currentRow, 2).Formula = currentFormula
        sheet.Range(currentRow, 2).Style.NumberFormat = "yyyy-MM-DD"


        'Save doc file.
        workbook.SaveToFile("Sample.xls")

        'Launching the MS Word file.
        System.Diagnostics.Process.Start("Sample.xls")

    End Sub
End Module
          
After running the demo, you will find the formula in the worksheet:
Published in Program Guide

What is Excel Image?

The Excel images are images that you insert into the Excel for further introduction. It can make your information easier to understand. Excel supports many kinds of formats for images, such as BMP, JPEG, JP2, GIF, TIFF, PNG, EXIF, WBMP, MBM. Below I will show you how to insert images into Excel with Spire.XLS.

How to Insert an Image in Excel with Spire.XLS?

Spire.XLS presents you an easiest way to insert an image into the worksheet. You may simply use sheet.Pictures.Add() method to realize it. In this method, you should provide the location where the picture will be placed in the worksheet. The location is specified by top row index and left column index.
Following is the demo of C# Excel image:
[C#]
using Spire.Xls;

namespace Image
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a new workbook
            Workbook workbook = new Workbook();

            //Initialize the worksheet
            Worksheet sheet = workbook.Worksheets[0];

            //Insert an image
            sheet.Pictures.Add(1, 1, @"..\..\..\..\..\..\Data\day.jpg");

            //Save the file
            workbook.SaveToFile("sample.xls");

            //Launch the file
            System.Diagnostics.Process.Start("Sample.xls");
        }
    }
}
          
[Visual Basic]
Imports Spire.Xls

Module Module1

    Sub Main()
        'Create a new workbook
        Dim workbook As New Workbook()

        'Initialize worksheet
        Dim sheet As Worksheet = workbook.Worksheets(0)

        'Insert an image
        sheet.Pictures.Add(1, 1, "..\..\..\..\..\..\Data\day.jpg")

        'Save doc file.
        workbook.SaveToFile("Sample.xls")

        'Launching the MS Word file.
        System.Diagnostics.Process.Start("Sample.xls")

    End Sub
End Module
          
Published in Program Guide
Thursday, 20 January 2011 10:26

How to Create Excel Pie Charts for C#/VB.NET

Why We Create Excel Pie Charts?

Create excel pie charts is a simple method to display your data to other individuals or a group. Excel pie charts can easily relay your messages that may otherwise go unnoticed by your audience. Pie charts are helpful for international audiences because they are universally known and easily explained. And it's extremely easy to create and use in Excel.

Pie charts, unlike other charts in Microsoft Excel, require the data in your worksheet be contained in only one row or column. By indicating a "category", an additional row or column can be used. Relative sizes are easy to compare as each piece of data is represented as a portion of a whole.

How to Create Excel Pie Charts in Microsoft Excel?

Every one of you can create excel pie charts in no time by using Microsoft Excel through the following steps:
  • Launch Microsoft Office Excel and open your excel file which with the data that you want to base your pie chart on.
  • Select the data that you want to base your chart on. The last cell that you want to select will not be chosen but it will have bold outline borders around it.
  • Click "Insert" button to open Chart Wizard window. Click on "Pie" in the right side column of Chart Type. Several sub-types of pie charts will be offered for you to choose. Pick a proper type which can best match with your data and click "Next"
  • Prevew on this new interface. If the pie chart with wrong information or even no pie chart appears, click "Cancel" and select your data, try the above process again. If everything is OK, click "Next"
  • On the new window, enter labels and a title for your pie chart. Click "Finish" when you see the pie chart appears as you want.
  • On your spreadsheet, click the box and drag your mouse to manipulate the size of the chart. By right clicking the chart and box, you can get many options to edit the pie chart.

How to Use Spire.XLS for .NET to Creat Excel Pie Charts?

Spire.XLS presents you an easy way to create a pie chart in the Excel workbook. First, you should create a pie chart with the sheet.Charts.Add method. You may control the resource of the data and title of the chart by setting DataRange and ChartTitle properties. What's more, we create an object to operate more about the chart. You may set the label and value of the pie with the properties cs.CategoryLabels and cs.Values. If you want to hide the value of the pie, you may set the cs.DataPoints.DefaultDataPoint.DataLabels.HasValue property false. In this demo, in order to reflect the effect of the chart, we set the grid lines of the worksheet invisible by assigning the sheet.GridLinesVisible false.
Use the C#/VB.NET codes of Spire.XLS for .NET below to create excel pie charts:
[C#]
using Spire.Xls;
using System.Drawing;

namespace Saveas
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a new workbook
            Workbook workbook = new Workbook();

            //Initialize worksheet
            workbook.CreateEmptySheets(1);
            Worksheet sheet = workbook.Worksheets[0];

            //Set sheet name
            sheet.Name = "Chart data";

            //Set the grid lines invisible
            sheet.GridLinesVisible = false;

            //Create a chart
            Chart chart = sheet.Charts.Add(ExcelChartType.Pie3D);

            //Set region of chart data
            chart.DataRange = sheet.Range["B2:B5"];
            chart.SeriesDataFromRange = false;

            //Set position of chart
            chart.LeftColumn = 1;
            chart.TopRow = 6;
            chart.RightColumn = 9;
            chart.BottomRow = 25;

            //Chart title
            chart.ChartTitle = "Sales by year";
            chart.ChartTitleArea.IsBold = true;
            chart.ChartTitleArea.Size = 12;

            //Initialize the chart series
            Spire.Xls.Charts.ChartSerie cs = chart.Series[0];

            //Chart Labels resource
            cs.CategoryLabels = sheet.Range["A2:A5"];

            //Chart value resource
            cs.Values = sheet.Range["B2:B5"];

            //Set the value visible in the chart
            cs.DataPoints.DefaultDataPoint.DataLabels.HasValue = true;

            //Year
            sheet.Range["A1"].Value = "Year";
            sheet.Range["A2"].Value = "2002";
            sheet.Range["A3"].Value = "2003";
            sheet.Range["A4"].Value = "2004";
            sheet.Range["A5"].Value = "2005";

            //Sales
            sheet.Range["B1"].Value = "Sales";
            sheet.Range["B2"].NumberValue = 4000;
            sheet.Range["B3"].NumberValue = 6000;
            sheet.Range["B4"].NumberValue = 7000;
            sheet.Range["B5"].NumberValue = 8500;

            //Style
            sheet.Range["A1:B1"].Style.Font.IsBold = true;
            sheet.Range["A2:B2"].Style.KnownColor = ExcelColors.LightYellow;
            sheet.Range["A3:B3"].Style.KnownColor = ExcelColors.LightGreen1;
            sheet.Range["A4:B4"].Style.KnownColor = ExcelColors.LightOrange;
            sheet.Range["A5:B5"].Style.KnownColor = ExcelColors.LightTurquoise;

            //Border
            sheet.Range["A1:B5"].Style.Borders[BordersLineType.EdgeTop].Color = Color.FromArgb(0, 0, 128);
            sheet.Range["A1:B5"].Style.Borders[BordersLineType.EdgeTop].LineStyle = LineStyleType.Thin;
            sheet.Range["A1:B5"].Style.Borders[BordersLineType.EdgeBottom].Color = Color.FromArgb(0, 0, 128);
            sheet.Range["A1:B5"].Style.Borders[BordersLineType.EdgeBottom].LineStyle = LineStyleType.Thin;
            sheet.Range["A1:B5"].Style.Borders[BordersLineType.EdgeLeft].Color = Color.FromArgb(0, 0, 128);
            sheet.Range["A1:B5"].Style.Borders[BordersLineType.EdgeLeft].LineStyle = LineStyleType.Thin;
            sheet.Range["A1:B5"].Style.Borders[BordersLineType.EdgeRight].Color = Color.FromArgb(0, 0, 128);
            sheet.Range["A1:B5"].Style.Borders[BordersLineType.EdgeRight].LineStyle = LineStyleType.Thin;
            
            //Number format
            sheet.Range["B2:C5"].Style.NumberFormat = "\"$\"#,##0";           
            chart.PlotArea.Fill.Visible = false;
                  
            //Save the file
            workbook.SaveToFile("Sample.xls");

            //Launch the file
            System.Diagnostics.Process.Start("Sample.xls");
        }
    }
}
          
[Visual Basic]
Imports Spire.Xls
Imports System.Drawing

Module Module1

    Sub Main()
        'Create a new workbook
        Dim workbook As New Workbook()

        'Initialize worksheet
        workbook.CreateEmptySheets(1)
        Dim sheet As Worksheet = workbook.Worksheets(0)

        'Set sheet name
        sheet.Name = "Chart data"

        'Set the grid lines invisible
        sheet.GridLinesVisible = False

        'Create a chart
        Dim chart As Chart = sheet.Charts.Add(ExcelChartType.Pie3D)

        'Set region of chart data
        chart.DataRange = sheet.Range("B2:B5")
        chart.SeriesDataFromRange = False

        'Set position of chart
        chart.LeftColumn = 1
        chart.TopRow = 6
        chart.RightColumn = 9
        chart.BottomRow = 25

        'Chart title
        chart.ChartTitle = "Sales by year"
        chart.ChartTitleArea.IsBold = True
        chart.ChartTitleArea.Size = 12

        'Set the chart
        Dim cs As Spire.Xls.Charts.ChartSerie = chart.Series(0)

        'Chart Labels resource
        cs.CategoryLabels = sheet.Range("A2:A5")

        'Chart value resource
        cs.Values = sheet.Range("B2:B5")

        'Set the value visible in the chart
        cs.DataPoints.DefaultDataPoint.DataLabels.HasValue = True

        'Year
        sheet.Range("A1").Value = "Year"
        sheet.Range("A2").Value = "2002"
        sheet.Range("A3").Value = "2003"
        sheet.Range("A4").Value = "2004"
        sheet.Range("A5").Value = "2005"

        'Sales
        sheet.Range("B1").Value = "Sales"
        sheet.Range("B2").NumberValue = 4000
        sheet.Range("B3").NumberValue = 6000
        sheet.Range("B4").NumberValue = 7000
        sheet.Range("B5").NumberValue = 8500

        'Style
        sheet.Range("A1:B1").Style.Font.IsBold = True
        sheet.Range("A2:B2").Style.KnownColor = ExcelColors.LightYellow
        sheet.Range("A3:B3").Style.KnownColor = ExcelColors.LightGreen1
        sheet.Range("A4:B4").Style.KnownColor = ExcelColors.LightOrange
        sheet.Range("A5:B5").Style.KnownColor = ExcelColors.LightTurquoise

        'Border
        sheet.Range("A1:B5").Style.Borders(BordersLineType.EdgeTop).Color = Color.FromArgb(0, 0, 128)
        sheet.Range("A1:B5").Style.Borders(BordersLineType.EdgeTop).LineStyle = LineStyleType.Thin
        sheet.Range("A1:B5").Style.Borders(BordersLineType.EdgeBottom).Color = Color.FromArgb(0, 0, 128)
        sheet.Range("A1:B5").Style.Borders(BordersLineType.EdgeBottom).LineStyle = LineStyleType.Thin
        sheet.Range("A1:B5").Style.Borders(BordersLineType.EdgeLeft).Color = Color.FromArgb(0, 0, 128)
        sheet.Range("A1:B5").Style.Borders(BordersLineType.EdgeLeft).LineStyle = LineStyleType.Thin
        sheet.Range("A1:B5").Style.Borders(BordersLineType.EdgeRight).Color = Color.FromArgb(0, 0, 128)
        sheet.Range("A1:B5").Style.Borders(BordersLineType.EdgeRight).LineStyle = LineStyleType.Thin

        'Number format
        sheet.Range("B2:C5").Style.NumberFormat = """$""#,##0"
        chart.PlotArea.Fill.Visible = False

        'Save doc file.
        workbook.SaveToFile("Sample.xls")

        'Launch the MS Word file.
        System.Diagnostics.Process.Start("Sample.xls")

    End Sub
End Module
          
After running the demo, you may find a pie appear in the document:
Published in Program Guide
Thursday, 01 July 2010 14:22

EXCEL Interior for C#, VB.NET

 
 The sample demonstrates how to write excel 2007 workbook.
Interior.gif

Published in Excel2007
Saturday, 03 July 2010 10:17

EXCEL Pagesetup for C#, VB.NET


The sample demonstrates how to work with page setup in an excel workbook.

Pagesetup.gif

Published in Pagesetup
Saturday, 03 July 2010 10:09

EXCEL DataValidation for C#, VB.NET

 
 
 The sample demonstrates how to write validation into spreadsheet.

WriteValidation.gif

Published in Validation
<< Start < Prev 1 2 3 Next > End >>
Page 1 of 3