Close





 
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
Wednesday, 05 January 2011 07:49

How to Add Cell Fill in Excel

What's Cell Fill in Excel?

Cell fill is indeed the colors and patterns of the cell. The content in the cell could have many kinds of colors and patterns. It will be better to get good colors and patterns. The cell fill could give Excel a good appearance. And in fact there are three ways: you can choose the color; you can choose the pattern; you can choose both of them. The better choice will make Excel look better and have good impressions for others.

How to Add Cell Fill via Spire.XLS.

Through Spire.XLS, you can use sheet.Range["A1"].Style.Color method to set the color of the cell. While using sheet.Range["A1"].Style.FillPattern, you can set the filled pattern of the cell. I will show you the way of cell fill below. In the end of the code, I give you the example of setting the color and pattern filled together.
The following code is about C# cell fill:
[C#]
using System.Drawing;
using Spire.Xls;

namespace Hyperlink
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a new workbook.
            Workbook workbook = new Workbook();
            Worksheet sheet = workbook.Worksheets[0];
            
            //Write a common text.
            sheet.Range["B2"].Text = "Home page";
            
            //Write a text with background color.
            sheet.Range["B4"].Text = "Home page";
            sheet.Range["B4"].Style.Color = Color.Green;
            
            //Write a text to the cell with pattern filled in. 
            sheet.Range["B6"].Text = "Home page";
            sheet.Range["B6"].Style.FillPattern = ExcelPatternType.Percent125Gray;
            
            //Write a text with background color and pattern filled in.
            sheet.Range["B8"].Text = "Home page";
            sheet.Range["B8"].Style.Color = Color.Green;
            sheet.Range["B8"].Style.FillPattern = ExcelPatternType.Percent125Gray;
            sheet.AutoFitColumn(2);
            
            //Save the file.
            workbook.SaveToFile("Sample.xls");
            
            //Launch the file.
            System.Diagnostics.Process.Start("Sample.xls");
        }
    }
}
          
The following code is about VB.NET cell fill:
[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 a common text.
        sheet.Range["B2"].Text = "Home page";
        
        'Write a text with background color.
        sheet.Range["B4"].Text = "Home page";
        sheet.Range["B4"].Style.Color = Color.Green;
        
        'Write a text to the cell with pattern filled in. 
        sheet.Range["B6"].Text = "Home page";
        sheet.Range["B6"].Style.FillPattern = ExcelPatternType.Percent125Gray;
        
        'Write a text with background color and pattern filled in.
        sheet.Range["B8"].Text = "Home page";
        sheet.Range["B8"].Style.Color = Color.Green;
        sheet.Range["B8"].Style.FillPattern = ExcelPatternType.Percent125Gray;
        sheet.AutoFitColumn(2);
        
        'Save the file.
        workbook.SaveToFile("Sample.xls")
        
        'Launch the file.
        System.Diagnostics.Process.Start("Sample.xls")
    End Sub
End Module
          
After running the demo, you can find that cells with fill pattern appears in the document.

Spire.XLS is a professional Excel component which enables developers/programmers to fast generate, read, write and modify Excel document for .NET and Silverlight. Click to learn more...
Published in Program Guide
Sunday, 01 August 2010 16:42

Data Export Style for C#, VB.NET

How to export data table to Excel file and set cell style.

Published in Cell
Sunday, 01 August 2010 16:21

Data Export Bar Chart for C#, VB.NET

Not needing to have Microsoft Excel installed on the machine, The Spire.DataExport can create Excel spreadsheet. This sample demonstrates how to export data table into xls and create bar chart.

  

Published in Cell
Sunday, 01 August 2010 16:02

Data Export Pie3D Chart for C#, VB.NET

Not needing to have Microsoft Excel installed on the machine, The Spire.DataExport can create Excel spreadsheet. This sample demonstrates how to export data table into xls and create pie-3d chart.

 

Published in Cell
Sunday, 01 August 2010 15:55

Data Export Formula for C#, VB.NET

Not needing to have Microsoft Excel installed on the machine, The Spire.DataExport can create Excel spreadsheet. This sample demonstrates how to add formulas into xls.

Published in Cell