7d289a3b64
pulizia codice...
109 lines
3.3 KiB
C#
109 lines
3.3 KiB
C#
using SteamWare;
|
|
using System;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
|
|
namespace GIM_site
|
|
{
|
|
public partial class ExcelExportReportIntAll : System.Web.UI.Page
|
|
{
|
|
/// <summary>
|
|
/// evento dati associati a controllo
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void grView_DataBound(object sender, EventArgs e)
|
|
{
|
|
if (grView.Rows.Count > 0)
|
|
{
|
|
// aggiorno gli headers
|
|
foreach (TableCell cella in grView.HeaderRow.Cells)
|
|
{
|
|
try
|
|
{
|
|
cella.Text = traduci(cella.Text);
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// wrapper traduzione
|
|
/// </summary>
|
|
/// <param name="lemma"></param>
|
|
/// <returns></returns>
|
|
public string traduci(object lemma)
|
|
{
|
|
return user_std.UtSn.Traduci(lemma.ToString());
|
|
}
|
|
/// <summary>
|
|
/// fix rendering tabelle standard in webform
|
|
/// </summary>
|
|
/// <param name="control"></param>
|
|
public override void VerifyRenderingInServerForm(Control control)
|
|
{
|
|
// Confirms that an HtmlForm control is rendered for the specified ASP.NET server control at run time.
|
|
}
|
|
/// <summary>
|
|
/// Si occupa di rendere l'out HTML come excel file (mimetype)
|
|
/// </summary>
|
|
private void doExport()
|
|
{
|
|
Response.Clear();
|
|
Response.AddHeader("content-disposition", "attachment; filename=WebGIM-Report_Interventi_Completo.xls");
|
|
Response.Charset = "";
|
|
// If you want the option to open the Excel file without saving than
|
|
// comment out the line below
|
|
Response.Cache.SetCacheability(HttpCacheability.NoCache);
|
|
Response.ContentType = "application/vnd.xls";
|
|
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
|
|
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
|
|
grView.RenderControl(htmlWrite);
|
|
Response.Write(stringWrite.ToString());
|
|
Response.End();
|
|
}
|
|
|
|
#region area protected
|
|
|
|
/// <summary>
|
|
/// caricamento pagina
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
hfUsername.Value = user_std.UtSn.userNameAD;
|
|
aggiornamento();
|
|
doExport();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
public void aggiornamento()
|
|
{
|
|
grView.AllowPaging = false;
|
|
ods.DataBind();
|
|
grView.DataBind();
|
|
}
|
|
public string isMtzProg(object _isMtzProg)
|
|
{
|
|
bool isMP = false;
|
|
string answ = "";
|
|
try
|
|
{
|
|
isMP = Convert.ToBoolean(_isMtzProg);
|
|
}
|
|
catch
|
|
{ }
|
|
if (isMP) answ = "X";
|
|
return answ;
|
|
}
|
|
}
|
|
} |