Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can use a library called ExcelLibrary. It's a free, open source library posted on Google Code:</p> <p><a href="https://code.google.com/archive/p/excellibrary/" rel="noreferrer">ExcelLibrary</a></p> <p>This looks to be a port of the PHP ExcelWriter that you mentioned above. It will not write to the new .xlsx format yet, but they are working on adding that functionality in.</p> <p>It's very simple, small and easy to use. Plus it has a DataSetHelper that lets you use DataSets and DataTables to easily work with Excel data.</p> <p>ExcelLibrary seems to still only work for the older Excel format (.xls files), but may be adding support in the future for newer 2007/2010 formats. </p> <p>You can also use <a href="https://github.com/JanKallman/EPPlus" rel="noreferrer">EPPlus</a>, which works only for Excel 2007/2010 format files (.xlsx files).</p> <p>There are a few known bugs with each library as noted in the comments. In all, EPPlus seems to be the best choice as time goes on. It seems to be more actively updated and documented as well.</p> <p>Also, as noted by @АртёмЦарионов below, EPPlus has support for Pivot Tables and ExcelLibrary may have some support (<a href="https://code.google.com/archive/p/excellibrary/issues/98" rel="noreferrer">Pivot table issue in ExcelLibrary</a>)</p> <p>Here are a couple links for quick reference:<br/> <a href="https://code.google.com/archive/p/excellibrary/" rel="noreferrer">ExcelLibrary</a> - <a href="https://www.gnu.org/licenses/lgpl.html" rel="noreferrer">GNU Lesser GPL</a><br/> <a href="https://github.com/JanKallman/EPPlus" rel="noreferrer">EPPlus</a> - <a href="https://github.com/JanKallman/EPPlus/blob/master/LICENSE" rel="noreferrer">GNU Lesser General Public License (LGPL)</a></p> <p><b>Here some example code for ExcelLibrary:</b></p> <p>Here is an example taking data from a database and creating a workbook from it. Note that the ExcelLibrary code is the single line at the bottom:</p> <pre><code>//Create the data set and table DataSet ds = new DataSet("New_DataSet"); DataTable dt = new DataTable("New_DataTable"); //Set the locale for each ds.Locale = System.Threading.Thread.CurrentThread.CurrentCulture; dt.Locale = System.Threading.Thread.CurrentThread.CurrentCulture; //Open a DB connection (in this example with OleDB) OleDbConnection con = new OleDbConnection(dbConnectionString); con.Open(); //Create a query and fill the data table with the data from the DB string sql = "SELECT Whatever FROM MyDBTable;"; OleDbCommand cmd = new OleDbCommand(sql, con); OleDbDataAdapter adptr = new OleDbDataAdapter(); adptr.SelectCommand = cmd; adptr.Fill(dt); con.Close(); //Add the table to the data set ds.Tables.Add(dt); //Here's the easy part. Create the Excel worksheet from the data set ExcelLibrary.DataSetHelper.CreateWorkbook("MyExcelFile.xls", ds); </code></pre> <p>Creating the Excel file is as easy as that. You can also manually create Excel files, but the above functionality is what really impressed me.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload