How to Programmatically Create, Read, Write an Excel Without Having Office Installed

How can I programmatically create, read, write an excel without having office installed?

write your excel in HTML table format:

<html>
<body>
<table>
<tr>
<td style="background-color:#acc3ff">Cell1</td>
<td style="font-weight:bold">Cell2</td>
</tr>
</table>
</body>
</html>

and give your file an xls extension. Excel will convert it automatically

Read and Write Data to Excel without Installing Office

If you can live without the xls-support (only xlsx) then you should most definitely look at the OpenXML SDK:

http://www.microsoft.com/en-us/download/details.aspx?id=5124

I doesn't require Excel or any extra license, you can do both read and write, I would say that it is robust and it comes with the Productivity Tool which is great. On the other hand, the API isn't that intuitive and you can't process .xls-files.

Create Excel files from C# without office

Unless you have Excel installed on the Server/PC or use an external tool (which is possible without using Excel Interop, see Create Excel (.XLS and .XLSX) file from C#), it will fail. Using the interop requires Excel to be installed.

Can I create an Excel sheet using the C# without MS Office installed?

I have achieved this using the EPPlus library.

Creating a excel file with Microsoft.Office.Interop.Excel without Excel installed

This library works without office installed: http://epplus.codeplex.com/
I have used it a few times and it worked nicely for me.

How to read an excel file in C# without using Microsoft.Office.Interop.Excel libraries

var fileName = @"C:\ExcelFile.xlsx";
var connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName + ";Extended Properties=\"Excel 12.0;IMEX=1;HDR=NO;TypeGuessRows=0;ImportMixedTypes=Text\""; ;
using (var conn = new OleDbConnection(connectionString))
{
conn.Open();

var sheets = conn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
using (var cmd = conn.CreateCommand())
{
cmd.CommandText = "SELECT * FROM [" + sheets.Rows[0]["TABLE_NAME"].ToString() + "] ";

var adapter = new OleDbDataAdapter(cmd);
var ds = new DataSet();
adapter.Fill(ds);
}
}


Related Topics



Leave a reply



Submit