You can use a library called ExcelLibrary to print in invoice Excel format.
It's open source library posted on Google Code and downloadable here.
Export a simple DataSet
table to .xls
or .xlsx
//Here's the easy part. Create the Excel worksheet from the data set
ExcelLibrary.DataSetHelper.CreateWorkbook("MyExcelFile.xls", ds);
Check these Create Excel (.XLS and .XLSX) file from C#, Using C# to Create an Excel Document and How to format an Excel file using C# for more details.
Here is an alternate also available:
NPOI library
The great thing about NPOI of course is that it enables you to work with the template in code and then send a copy of the spreadsheet directly to the user. The template remains intact and the user receives a modified copy of the template which contains the data processed by the application.follow this Creating Excel spreadsheets .XLS and .XLSX in C#
You can create formatting in your excel sheet using Office Interop
. Check this
C# - Opening Excel Template(xlt), adding data, and saving to new worksheet(xls).
What about iText
to use for creating Invoice in PDF format.
Check these list of examples that help you to create and manipulate pdf document.
using System;
using com.lowagie.text;
using com.lowagie.text.pdf;
using System.IO;
public class TestPDF
{
public static void Main(string[] args)
{
Console.WriteLine("Hello World");
// step 1: creation of a document-object
Document document = new Document();
// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to a file
PdfWriter.getInstance(document, new FileStream("MyPDF.pdf", FileMode.Create));
// step 3: we open the document
document.open();
// step 4: we add a paragraph to the document
document.add(new Paragraph("Hello World"));
// step 5: we close the document
document.close();
}
}