string
is an alias in C# for System.String
.
So technically, there is no difference. It's like int
vs. System.Int32
.
As far as guidelines, it's generally recommended to use string
any time you're referring to an object.
e.g.
string place = "world";
Likewise, I think it's generally recommended to use String
if you need to refer specifically to the class.
e.g.
string greet = String.Format("Hello {0}!", place);
This is the style that Microsoft tends to use in their examples.
It appears that the guidance in this area may have changed, as StyleCop now enforces the use of the C# specific aliases.
You can use a library called ExcelLibrary. It's a free, open source library posted on Google Code:
ExcelLibrary
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.
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.
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.
You can also use EPPlus, which works only for Excel 2007/2010 format files (.xlsx files). There's also NPOI which works with both.
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.
Also, as noted by @АртёмЦарионов below, EPPlus has support for Pivot Tables and ExcelLibrary may have some support (Pivot table issue in ExcelLibrary)
Here are a couple links for quick reference:
ExcelLibrary - GNU Lesser GPL
EPPlus - GNU (LGPL) - No longer maintained
EPPlus 5 - Polyform Noncommercial - Starting May 2020
NPOI - Apache License
Here some example code for ExcelLibrary:
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:
//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);
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.
Best Answer
Solr
sits on top ofLucene
and it is written inJava
, so it requiresJRE
.Solr.Net
is only.net
client forSolr
, so you would need hostSolr
somehow for it.Lucene
on the other hand originally was written inJava
, but was ported to.NET
, so you can simply reference dll of portedLucene
lib and you will be fine.There is also
ElasticSearch
, that also sits on top ofLucene
and it is also written inJava
, so it requiresJRE
also, but it is better thanSolr
in several aspects, mainly in easier scaling, also has in my opinion better .net client.Depending on that you need, you may also take a look at
RavenDB
and it also sits on top ofLucene
and has full text search/faceting capabilities, may run on its own server or as embedded database (it is written in .net).To answer your questions:
1) For
Lucene
only, you don't needJRE
, we're running website usingLucene.NET
onWindows Azure Websites
, which means we haven't installed anthing additional on those server instances.2) To use
Solr
for full text search, you need to:1) Install
Solr
(you'll needServlet Container
to hostSolr
, I've tried only withTomcat
,Solr
examples useJetty
) http://wiki.apache.org/solr/SolrInstall. Alternatively you can outsourceSolr
hosting, for example from here: http://www.websolr.com/plans2) Use some API (Solr.net) to add documents to index
3) Use some API (Solr.net) to perform search on index