when the user clicks the button to export it triggers the function i created below which actually saves the files without the user prompt.
public int fExport(ListView lsvt, string filename)
{
try
{
if (File.Exists(filename))
{
File.Delete(filename);
}
StringWriter stringWriter = new StringWriter();
HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter);
lsvt.RenderControl(htmlTextWriter);
string content = stringWriter.ToString();
// string test= "<style>.textmode{mso-number-format:\@;}</style>" ;
System.IO.File.WriteAllText(filename, content.ToString());
// Response.Write(content);
// Response.End();
/*
Dim style As String = "<style>.textmode{mso-number-format:\@;}</style>"
System.IO.File.WriteAllText("D:\\Test.xls", style & sw.ToString())*/
return 0;
}
catch (Exception ex)
{
Helper.sendShortEmail("An error has occurred within the weeklyViolationsScp script, please investigate immediately. The actual error message has been recorded below <br /> <br /> " + ex.Message.ToString(), devsarr1[0], "Error in Script");
return 1;
}
}