1. Products
  2.   Spreadsheet
  3.   .NET
  4.   PureExcel
 
  

Open Source .NET Library for Readding Excel Spreadsheets

Free lightweight API for parsing Microsoft Excel Spreadsheets

PureExcel is an open source lightweight C# API for reading Microsoft Excel (2007) Worksheets. It is a simple API and can be run on any .NET Framework. The API uses no third-party library dependency, no Excel Interop, no Open XML SDK, no Linq, Xml, and Dataset of C# system API.

Using the API you can read the Excel workbook and trim empty rows and columns in it. Furthermore, the API supports stream parsing and formula parsing.

Previous Next

Getting Started with PureExcel

It is an open-source library. You can download it from GitHub and use it in your .NET Applications

Read Excel Spreadsheets using C#

PureExcel allows C# .NET developers to read new excel worksheets. The API uses the Worksheet class that exposes methods to work with Excel worksheets. You can read excel using Worksheet.Read() method, get comments using Worksheet.GetComment() method and get rows and cells using Worksheet.GetRows() and Workseet.GetCell() method respectively.

How to Read Excel Spreadsheets via C# API?

namespace PureExcel
{
    public partial class Excel
    {
        public Worksheet Read(int sheetIndex)
        {
			//excel index begin from 1
			foreach (Worksheet workSheet in WorkSheets) 
			{
				if (workSheet.Index == sheetIndex + 1) 
				{
					workSheet.Read ();
					return workSheet;
				}
			}
			return null;
        }

        public Worksheet Read(string sheetName)
        {
			foreach (Worksheet workSheet in WorkSheets) 
			{
				if (workSheet.Name == sheetName) 
				{
					workSheet.Read ();
					return workSheet;
				}
			}
			return null;
        }

    }
}

Get Worksheet Properties using C#

The open source API PureExcel gives software developers the power to manage their spreadsheets documents and handle various properties related to their documents. The API also allows getting worksheets properties using Worksheet.GetWorksheetsProperties() method. It supports properties like worksheet name, Id, Author, date of creation, edit time, last save time and many more.

How to Get Worksheet Properties via C# API?

private Worksheet[] GetWorksheetProperties()
        {
            PrepareArchive();
            var worksheets = new List();
			XMLNode document = this.m_Archive.GetXmlNode("xl/workbook.xml");
            if (document == null)
            {
                throw new Exception("Unable to load workbook.xml");
            }
			XMLNodeList nodeList = document.GetNodeList ("workbook>0>sheets>0>sheet");
			foreach (XMLNode node in nodeList)
            {
                var worksheet = new Worksheet(this);
				worksheet.Index = int.Parse(node.GetValue("@r:id").Replace("rId", ""));
				worksheet.Name = node.GetValue ("@name");
                worksheets.Add(worksheet);
            }
            return worksheets.ToArray();
        }
 English