Posts

Showing posts from August, 2013

To create an Excel spreadsheet with COM interop

I remember this time I was working on creating excel report for the attendance at this time in last year and it was most fun to create things I have worked on we can convert from the data-set to excel sheets to download in an easy asp.net web page it was tricky because we have to create an excel sheet in Util-Layer(where all our utility logic stays) and call save as from the front end C# using System; using System.Reflection; using Microsoft.Office.Interop.Excel; public class CreateExcelWorksheet { Workbook void BuildExcelWorkbook() { Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application(); if (xlApp == null ) { Console.WriteLine( "EXCEL could not be started. Check that your office installation and project references are correct." ); return null ; } xlApp.Visible = true ; Workbook wb = xlApp.Workbooks.Add(XlWBATemplate.xlWBAT...