I am new in jQuery/jQgrid coding. I am using jQgrid version is 4.4.4 & jQuery 1.8.3. I want to enable export to PDF/EXCEL functionality in my jQgrid. For that I referred
if (exportexcel.Equals(excel) )
{
GridView view = new GridView();
string conn = @"Server=localhost;port=3306;Database=jtext;Uid=root;Password=techsoft";
IFormatProvider culture = new System.Globalization.CultureInfo("fr-Fr", true);
MySqlConnection con = new MySqlConnection(conn);
con.Open();
MySqlCommand cmd = new MySqlCommand(query, con);
MySqlDataAdapter adp = new MySqlDataAdapter(cmd);
DataSet ds = new DataSet();
adp.Fill(ds);
view.DataSource = ds;
view.DataBind();
con.Close();
HttpContext Context = HttpContext.Current;
context.Response.Write(Environment.NewLine);
context.Response.Write(Environment.NewLine);
context.Response.Write(Environment.NewLine);
DateTime ss = DateTime.Now;
string custom = ss.ToString("dd-MM-yyyy");
string sss = DateTime.Now.ToString("HH:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo);
string aaa = "Generated Date and Time : " + custom + " " + sss;
context.Response.Write(aaa);
context.Response.Write(Environment.NewLine);
foreach (DataColumn column in ds.Tables[0].Columns)
{
context.Response.Write(column.ColumnName + " ,");
}
context.Response.Write(Environment.NewLine);
foreach (DataRow row in ds.Tables[0].Rows)
{
for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
{
context.Response.Write(row[i].ToString().Replace(" ", string.Empty).Replace(",", " ") + " ,");
}
context.Response.Write(Environment.NewLine);
}
string attachment = "attachment; filename= " + rolefullname + ".xls";
context.Response.ContentType = "application/csv";
context.Response.AppendHeader("Content-Disposition", attachment);
}
}
strong text