Sorry, coming up with some weird requirement here, but I need help from you.
In a metastorm report, I have a button "OK" in filter area to generate report.
Once the report is generated, user can click the other button "Export" and the report shall be exported in excel.
We do have a default export functionality, but we are not able to use it in sharepoint.
I tried implementing C# code on button click using the following code:
HttpResponse response = HttpContext.Current.Response;
// first let's clean up the response.object
response.Charset = "";
// set the response mime type for excel
response.ContentType = "application/vnd.ms-excel";
response.AddHeader("Content-Disposition", "attachment;filename=\"" + "test.xlsx");
// create a string writer
using (StringWriter sw = new StringWriter())
using (HtmlTextWriter htw = new HtmlTextWriter(sw))
// instantiate a datagrid
DataGrid dg = new DataGrid();
//dg.DataBinding += new EventHandler();
dg.DataSource = ds.Tables;
string test = "Parameter: Test" + "\n";
response.Write(test + sw.ToString());
but the Response object in the first line itself is giving error. I believe its null as it is giving Object reference not set to instance error.
Can you you please share how to achieve this.
Also any workaround will be helpful...