Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.OracleClient;
using System.Configuration;
namespace Magellen2.SALESHISTORY
{
/// <summary>
/// Summary description for SalesHistoryExcel2.
/// </summary>
public class SalesHistoryExcel2 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Literal ExcelData;
public string Sql = "";
private MagUtils myUtils = new MagUtils();
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
Server.ScriptTimeout = 360 ;
Sql = "select division, cat_seg_1, sum(quantity_invoiced) quantity_invoiced, sum(extended_price) extended_price";
Sql += " from sales_data_info_curr";
Sql += " group by division, cat_seg_1";
BuildExcel();
}
private void BuildExcel()
{
DBConnect.dbUtils dbTools = new DBConnect.dbUtils();
OracleConnection db = dbTools.openDB(ConfigurationSettings.AppSettings["HistConnString"]);
DataSet ds = dbTools.GetDataSet(Sql,db);
//OracleConnection dbCon = myUtils.openAppsDB();
//DataSet ds = myUtils.GetDataSetFromAppsOrPPPP(Sql,"APPS",dbCon);
Response.Clear();
Response.ContentType = "application/vnd.ms-excel";
this.EnableViewState = false;
System.Text.StringBuilder MySB = new System.Text.StringBuilder();
MySB.Append("<TABLE width='100%' border=0 cellspacing=2 cellpadding=2>");
MySB.Append("<TR CLASS=clsBoldText>");
MySB.Append("<TD nowrap><B>Division</B></TD>" );
MySB.Append("<TD nowrap><B>CAT_SEG_1</B></TD>" );
MySB.Append("<TD nowrap><B>QUANTITY_INVOICED</B></TD>");
MySB.Append("<TD nowrap><B>EXTENDED_AMOUNT</B></TD></TR>" );
foreach(DataTable myTable in ds.Tables)
{
if (myTable.Rows.Count > 0 )
{
foreach(DataRow myRow in myTable.Rows)
{
MySB.Append("<TR CLASS=clsText>");
MySB.Append("<TD VALIGN=TOP nowrap>" + myRow["DIVISION"].ToString() + "</TD>");
MySB.Append("<TD nowrap>" + myRow["CAT_SEG_1"].ToString() + "</TD>");
MySB.Append("<TD VALIGN=TOP nowrap>" + myRow["QUANTITY_INVOICED"].ToString() + "</TD>");
MySB.Append("<TD VALIGN=TOP nowrap>" + myRow["EXTENDED_PRICE"].ToString() + "</TD></TR>");
}
}
else//In Case of No Records found
{
MySB.Append("<TR><TD COLSPAN=7 CLASS=clsErrorText>No Records found.</TD></TR>");
}
}
ds.Dispose();
MySB.Append("</TABLE>");
ExcelData.Text = Convert.ToString(MySB.ToString());
db.Close();
db.Dispose();
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
then the next code is the page that opens with the results.
<%@ Page language="c#" Codebehind="SalesHistoryExcel.aspx.cs" AutoEventWireup="false" Inherits="Magellen2.SalesHistoryExcel" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>SalesHistoryExcel</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="[URL unfurl="true"]http://schemas.microsoft.com/intellisense/ie5">[/URL]
<script language="javascript">
function closeWin(){
/*try {
self.close()
}catch(e){}
*/
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout" onUnload="javascript:closeWin()">
<asp:Literal ID=ExcelData Runat =server></asp:Literal>
</body>
</HTML>
ca8msm said:Can you provide the HTML output that your page generates and we can see if that provides any clues?
Also, please usetags when posting code.Code: