1

Hi I am creating an application through which i need to create an excel. I have added Microsoft Excel 12.Object Library as Reference to application. But my server didnt get Msoffice Installed in it. So how can i create Excel in that server.

1

4 Answers 4

4

I can recommend EPPlus because it's simple, powerful and works without having office/excel being installed with Excel 2007 spreadsheets(xlsx-files). It's license model is LGPL.

var excel = new ExcelPackage();
excel.File = new System.IO.FileInfo(@"C:\Temp\AnExcelFile.xlsx");
if (excel.File.Exists)
    excel.Load(excel.File.Open(FileMode.Open));
ExcelWorksheet ws = excel.Workbook.Worksheets.Add("Worksheet-Name");//must be unique and less than 31 characters long
ws.Cells[26, 1].LoadFromDataTable(dt, true); //loading from DataTable, the 2.Parameter is PrintHeaders
ws.Cells[26, 1].LoadFromCollection(query, true); //loading by LINQ-Query also possible
excel.Save();
2
  • It is not GPL anymore but LGPL. Commented Oct 29, 2012 at 11:05
  • @ChristianSauer: Then Jan has changed it recently. Edited my answer accordingly. That means you don' t have to provide or link the source code in your application anymore(if i remember correctly) . Commented Oct 29, 2012 at 11:12
1

If you need to create new office format documents known as openxml, you can see at http://www.microsoft.com/en-us/download/details.aspx?id=5124

1

There are a number of third party libraries - I think ComponentOne makes one, for instance - which are capable of creating Excel files, and I think at least some of them are independent of Excel, so they can make Excel files without having Excel installed on the server.

An alternate solution would be to create some other format that Excel can read, for instance CSV. Using CSV will mean that you don't get the fancy formatting provided by Excel, but at least you don't need to license a third party component or install Excel on the server.

0

There is now way to create ms objects, while MS Office is not installed. Added library is nothing more than interfaces wrapper.

Not the answer you're looking for? Browse other questions tagged or ask your own question.