1
The below method downloads the document that is generated dynamically, but when the file opens it shows a file conversion option, leaving the item marked by default Unicode(UTF-8).
What to do not show this message?
public static void gerarRelatorioAtoDoc(string texto)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Charset = "";
HttpContext.Current.Response.ContentType = "application/msword";
String strNomeArquiv = "RelAtoGerado" + DateTime.Now.ToShortDateString().ToString() + ".doc";
HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;filename=" + strNomeArquiv);
StringBuilder strHTMLContent = new StringBuilder();
strHTMLContent.Append(texto);
HttpContext.Current.Response.Write(strHTMLContent);
HttpContext.Current.Response.End();
HttpContext.Current.Response.Flush();
}
What do you have in text? By the way, what is the impediment to using a library that generates a formatted document?
– Leonel Sanches da Silva
i pass a parameter pro metodo, text can be anything, in case there is a statement coming from a <Asp:Textbox>
– Tomaz Neto
and what would be the library in question, which generates the document?
– Tomaz Neto
I’m talking about something like this. Your schema works, but I see it more as an improv. It gets harder to format the document this way.
– Leonel Sanches da Silva
Okay I’m gonna take this library and implement it here, see how it behaves.
– Tomaz Neto
It has a procedure that saves in a specific directory, so much so that I can not point to an existing directory on my drive; but by what seems to be is very simple and useful. I’ll test at home. Thank you very much!
– Tomaz Neto