using SteamWare; using System; using System.Web; using System.Web.UI; namespace NKC_WF.export { public partial class BunkDetail : System.Web.UI.Page { public override void VerifyRenderingInServerForm(Control control) { // Confirms that an HtmlForm control is rendered for the specified ASP.NET server control at run time. } protected string BunkID { get { string answ = "0"; answ = memLayer.ML.QSS("BunkID"); return answ; } } private void doExport() { Response.Clear(); string content = $"attachment; filename=Bunk_{BunkID}.xls"; Response.AddHeader("content-disposition",content); 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(); } protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { aggiornamento(); doExport(); } } public void aggiornamento() { hfStackID.Value = BunkID; grView.AllowPaging = false; ods.DataBind(); } /// /// Formatta in min/sec il tempo in sec decimale /// /// /// public string formatMinSec(object _timeSec) { int totSec = 0; string answ = ""; int.TryParse(_timeSec.ToString().Replace(".", ""), out totSec); int numMin = totSec / 60; int numSec = totSec - (60 * numMin); answ = $"00:{numMin:00}:{numSec:00}"; return answ; } /// /// Restitusice path bnonificato /// /// /// public string fixFilePath(object _rawPath) { string answ = _rawPath.ToString().ToLower(); string fileBasePath = memLayer.ML.CRS("fileBasePath").ToLower(); answ = answ.Replace(fileBasePath, "").Replace("svg", "SVG").Replace("cnc", "CNC"); return answ; } } }