http://jqueryui.com/sortable/#display-grid
Information box is a blog about all type of new information related to fast growing world..
Saturday 31 May 2014
Read Excel file and convert into Dataset
OleDbConnection connection = new OleDbConnection();
string path = string.Concat(Server.MapPath("../Uploaded Folder/chart.xls"));
// Excle Read Connection String for open office
string excelConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + path + "; Extended Properties=Excel 8.0;";
connection.ConnectionString = excelConnectionString;
OleDbCommand command = new OleDbCommand("select * from [Sheet1$]", connection);
OleDbCommand command2 = new OleDbCommand("select * from [Sheet2$]", connection);
connection.Open();
// Create DbDataReader to Data Worksheet
DbDataReader dr = command.ExecuteReader();
DbDataReader dr2 = command2.ExecuteReader();
dt.Load(dr);
dt1.Load(dr2);
ds = new DataSet();
ds.Tables.Add(dt);
ds.Tables.Add(dt1);
string path = string.Concat(Server.MapPath("../Uploaded Folder/chart.xls"));
// Excle Read Connection String for open office
string excelConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + path + "; Extended Properties=Excel 8.0;";
connection.ConnectionString = excelConnectionString;
OleDbCommand command = new OleDbCommand("select * from [Sheet1$]", connection);
OleDbCommand command2 = new OleDbCommand("select * from [Sheet2$]", connection);
connection.Open();
// Create DbDataReader to Data Worksheet
DbDataReader dr = command.ExecuteReader();
DbDataReader dr2 = command2.ExecuteReader();
dt.Load(dr);
dt1.Load(dr2);
ds = new DataSet();
ds.Tables.Add(dt);
ds.Tables.Add(dt1);
Covert array in to xml
int[] values = { 1, 2, 17, 8 };
XDocument doc = new XDocument();
doc.Add(new XElement("root", values.Select(x => new XElement("item", x))));
convert dataset into JSON
public static class myclassGeneral
{
static object RowsToDictionary(this DataTable table)
{
var columns = table.Columns.Cast<DataColumn>().ToArray();
return table.Rows.Cast<DataRow>().Select(r => columns.ToDictionary(c => c.ColumnName, c => r[c]));
}
static Dictionary<string, object> ToDictionary(this DataTable table)
{
return new Dictionary<string, object>
{
{ table.TableName, table.RowsToDictionary() }
};
}
static Dictionary<string, object> ToDictionary(this DataSet data)
{
return data.Tables.Cast<DataTable>().ToDictionary(t => t.TableName, t => t.RowsToDictionary());
}
public static string GetJSONString(DataTable table)
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
return serializer.Serialize(table.ToDictionary());
}
public static string GetJSONString(DataSet data)
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
return serializer.Serialize(data.ToDictionary());
}
}
{
static object RowsToDictionary(this DataTable table)
{
var columns = table.Columns.Cast<DataColumn>().ToArray();
return table.Rows.Cast<DataRow>().Select(r => columns.ToDictionary(c => c.ColumnName, c => r[c]));
}
static Dictionary<string, object> ToDictionary(this DataTable table)
{
return new Dictionary<string, object>
{
{ table.TableName, table.RowsToDictionary() }
};
}
static Dictionary<string, object> ToDictionary(this DataSet data)
{
return data.Tables.Cast<DataTable>().ToDictionary(t => t.TableName, t => t.RowsToDictionary());
}
public static string GetJSONString(DataTable table)
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
return serializer.Serialize(table.ToDictionary());
}
public static string GetJSONString(DataSet data)
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
return serializer.Serialize(data.ToDictionary());
}
}
Convert JSON data into Dataset
public DataSet DerializeDataTable(string a)
{
DataTable datatable = new DataTable();
string json = a;
DataSet myDataSet = JsonConvert.DeserializeObject<DataSet>(json);
return myDataSet;
}
{
DataTable datatable = new DataTable();
string json = a;
DataSet myDataSet = JsonConvert.DeserializeObject<DataSet>(json);
return myDataSet;
}
Convert Object into Xml Format
public XmlNode CreateXML(Object YourClassObject)
{
XmlDocument xmlDoc = new XmlDocument(); //Represents an XML document,
// Initializes a new instance of the XmlDocument class.
XmlSerializer xmlSerializer = new XmlSerializer(YourClassObject.GetType());
// Creates a stream whose backing store is memory.
using (MemoryStream xmlStream = new MemoryStream())
{
xmlSerializer.Serialize(xmlStream, YourClassObject);
xmlStream.Position = 0;
//Loads the XML document from the specified string.
xmlDoc.Load(xmlStream);
return xmlDoc;
}
}
{
XmlDocument xmlDoc = new XmlDocument(); //Represents an XML document,
// Initializes a new instance of the XmlDocument class.
XmlSerializer xmlSerializer = new XmlSerializer(YourClassObject.GetType());
// Creates a stream whose backing store is memory.
using (MemoryStream xmlStream = new MemoryStream())
{
xmlSerializer.Serialize(xmlStream, YourClassObject);
xmlStream.Position = 0;
//Loads the XML document from the specified string.
xmlDoc.Load(xmlStream);
return xmlDoc;
}
}
Subscribe to:
Posts (Atom)
रूस-यूक्रेन संकट लाइव: भारतीयों को 'उपलब्ध किसी भी साधन' के माध्यम से कीव को तत्काल छोड़ने के लिए कहा
रूस यूक्रेन संकट लाइव: कीव में भारतीय दूतावास ने मंगलवार को जारी एक एडवाइजरी में भारतीयों को 'किसी भी उपलब्ध साधन' के माध्यम से क...
-
The autonomous EV will have a range up to 800 kilometers (497 miles). There's also the luxurious interior (the automaker compares it...
-
1.nia sharama 2. anchit kaur 3. ayaz khan 4. Devoleena Bhattacharjee 5. Dhinchak Pooja 6....
-
selectionchangecommitted vs selectedindexchanged SelectionChangeCommitted is raised only when the user changes the combo box selection...