Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

A Very Easy to Use Excel XML Import-Export Library

, 25 Nov 2008
Import export library for the Excel XML format, which reduces a programmer's work to the bare minimum.
Documentation.zip
ExcelXml.zip
ExcelXml
ExcelXmlTest
bin
Debug
ExcelXmlTest.exe
ExcelXmlTest.vshost.exe
Yogesh.ExcelXml.dll
Yogesh.Extensions.dll
obj
Debug
TempPE
Properties
Yogesh.ExcelXml
bin
Debug
Yogesh.ExcelXml.dll
Yogesh.Extensions.dll
Help
Documentation.chm
LastBuild.log
obj
Debug
Refactor
TempPE
Release
Properties
Extensions.zip
Extensions
Yogesh.Extensions
bin
Debug
Yogesh.Extensions.dll
Properties
Yogesh.Extensions.zip
using System;
using System.Collections.Generic;

namespace Yogesh.ExcelXml
{
	/// <summary>
	/// Represents a strongly typed list of cells that can be accessed by index.
	/// </summary>
	public class CellCollection : List<Cell>
	{
		/// <summary>
		/// Adds a range to the collection
		/// </summary>
		/// <param name="range">Range to add</param>
		public void Add(Range range)
		{
			foreach (Cell cell in range)
				Add(cell);
		}

		/// <summary>
		/// Adds a worksheet to the collection
		/// </summary>
		/// <param name="ws">Worksheet to add</param>
		public void Add(Worksheet ws)
		{
			foreach (Cell cell in ws)
				Add(cell);
		}

		/// <summary>
		/// Adds a row to the collection
		/// </summary>
		/// <param name="row">Row to add</param>
		public void Add(Row row)
		{
			foreach (Cell cell in row)
				Add(cell);
		}

		/// <summary>
		/// Adds a single cell to the collection if it matches the filter condition
		/// </summary>
		/// <param name="cell">Cell to add</param>
		/// <param name="filterCondition">Filter predicate</param>
		public void Add(Cell cell, Predicate<Cell> filterCondition)
		{
			if (filterCondition(cell))
				Add(cell);
		}

		/// <summary>
		/// Adds a range to the collection if it matches the filter condition
		/// </summary>
		/// <param name="range">Range to add</param>
		/// <param name="filterCondition">Filter predicate</param>
		public void Add(Range range, Predicate<Cell> filterCondition)
		{
			foreach (Cell cell in range)
			{
				if (filterCondition(cell))
					Add(cell);
			}
		}

		/// <summary>
		/// Adds a worksheet to the collection if it matches the filter condition
		/// </summary>
		/// <param name="ws">Worksheet to add</param>
		/// <param name="filterCondition">Filter predicate</param>
		public void Add(Worksheet ws, Predicate<Cell> filterCondition)
		{
			foreach (Cell cell in ws)
			{
				if (filterCondition(cell))
					Add(cell);
			}
		}

		/// <summary>
		/// Adds a row to the collection if it matches the filter condition
		/// </summary>
		/// <param name="row">Row to add</param>
		/// <param name="filterCondition">Filter predicate</param>
		public void Add(Row row, Predicate<Cell> filterCondition)
		{
			foreach (Cell cell in row)
			{
				if (filterCondition(cell))
					Add(cell);
			}
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author


| Advertise | Privacy | Mobile
Web04 | 2.8.140709.1 | Last Updated 26 Nov 2008
Article Copyright 2008 by Yogesh Jagota
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid