export data from datagrid to excel [modified]
-
Hi everyone I am trying to export data from datagrid to excel but gives me this erro"Obect reference not set to instance of the object".here is my code.I am using windows C#. lblMessage.Text = ""; DataTable dtTransactions = dsTransactions.Tables["Transactions"].Copy(); int[] iColumns = {0,1,2,3,5,6}; RKLib.ExportData.Export objExport = new RKLib.ExportData.Export("Win"); objExport.ExportDetails(dtTransactions,iColumns,Export.ExportFormat.Excel,"C:\\TransactionsInfo.Excel"); lblMessage.Text = "Successfully exported to C:\\TransactionsInfo.Excel"; -- modified at 8:28 Thursday 31st August, 2006
-
Hi everyone I am trying to export data from datagrid to excel but gives me this erro"Obect reference not set to instance of the object".here is my code.I am using windows C#. lblMessage.Text = ""; DataTable dtTransactions = dsTransactions.Tables["Transactions"].Copy(); int[] iColumns = {0,1,2,3,5,6}; RKLib.ExportData.Export objExport = new RKLib.ExportData.Export("Win"); objExport.ExportDetails(dtTransactions,iColumns,Export.ExportFormat.Excel,"C:\\TransactionsInfo.Excel"); lblMessage.Text = "Successfully exported to C:\\TransactionsInfo.Excel"; -- modified at 8:28 Thursday 31st August, 2006
Response.Clear(); Response.Charset = ""; Response.AddHeader("content-isposition", "attachment;filename=FileName.xls"); Response.ContentType = "application/vnd.ms-excel"; System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); DataGrid dGrid = new DataGrid(); dGrid.DataSource = Classname.functionname();//this is where u write the stored procedure dGrid.HeaderStyle.Font.Bold = true; dGrid.DataBind(); dGrid.RenderControl(htmlWrite); Response.Write(stringWrite.ToString()); Response.End();
please help me