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 CPOL
Import export library for the Excel XML format, which reduces a programmer's work to the bare minimum.
Documentation.zip
Documentation.chm
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
Yogesh.Extensions.dll
Yogesh.ExcelXml.dll
using System;
using System.Collections.Generic;
using System.Text;
using Yogesh.ExcelXml;

namespace ExcelXmlTest
{
	class Program
	{
		static void Main(string[] args)
		{
			// Create a instance...
			ExcelXmlWorkbook book = new ExcelXmlWorkbook();
			 
			// Many such properties exist. Details can be found in the documentation
			// The author of the document
			book.Properties.Author = "Yogesh Jagota";
			 
			// This returns the first worksheet.
			// Note that we have not declared a instance of a new worksheet
			// All the dirty work is done by the library.
			Worksheet sheet = book[0];
			 
			// Name is the name of the sheet. If not set, the default name
			// style is "sheet" + sheet number, like sheet1, sheet2
			sheet.Name = "AgewiseOutstanding";
			 
			// More on this in documentation
			sheet.FreezeTopRows = 3;
			 
			// and this too...
			sheet.PrintOptions.Orientation = PageOrientation.Landscape;
			sheet.PrintOptions.SetMargins(0.5, 0.4, 0.5, 0.4);
			 
			// This is the actual code which sets out the cell values
			// Note again, that we don't declare any instance at all.
			// All the work is done by the library.
			// Index operator takes first value as column and second as row.
			sheet[0, 0].Value = "Outstanding as on " +
				 DateTime.Now;
			sheet[0, 0].Font.Bold = true;

			sheet.Columns(0).Width = 180;
			sheet.Columns(1).Width = 72;
			sheet.Columns(2).Width = 90;
			sheet.Columns(3).Width = 51;
			sheet.Columns(4).Width = 51;
			sheet.Columns(5).Width = 51;
			sheet.Columns(6).Width = 51;
			sheet.Columns(7).Width = 51;
			sheet.Columns(8).Width = 51;
			sheet.Columns(9).Width = 72;

			sheet[0, 2].Value = "Name of Party";
			sheet[1, 2].Value = "RSM";
			sheet[2, 2].Value = "ASM";
			sheet[3, 2].Value = "0-30";
			sheet[4, 2].Value = "31-60";
			sheet[5, 2].Value = "61-90";
			sheet[6, 2].Value = "91+";
			sheet[7, 2].Value = "Total";
			new Range(sheet[0, 2], sheet[7, 2]).Font.Bold = true;

			sheet[0, 3].Value = "M/s Stupid Paymaster";
			sheet[1, 3].Value = "Mr. Nonsense";
			sheet[2, 3].Value = "Mr. More Nonsense";
			sheet[3, 3].Value = 0;
			sheet[4, 3].Value = 5000;
			sheet[5, 3].Value = 45000;
			sheet[6, 3].Value = 0;
			sheet[7, 3].Value = FormulaHelper.Formula("Sum", new Range(sheet[3, 3], sheet[6, 3]));
			 
			sheet[0, 4].Value = "M/s Good Paymaster";
			sheet[1, 4].Value = "Mr. Good RSM";
			sheet[2, 4].Value = "Mr. Good ASM";
			sheet[3, 4].Value = 32000;
			sheet[4, 4].Value = 0;
			sheet[5, 4].Value = 0;
			sheet[6, 4].Value = 0;
			sheet[7, 4].Value = FormulaHelper.Formula("Sum", new Range(sheet[3, 4], sheet[6, 4]));
			 
			// no extension is added if not present
			string outputFile = "Outstanding File.xml";
			 
			book.Export(outputFile);
		}
	}
}

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)

Share

About the Author


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