Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 1.0 and Visual Studio.NET > VS.NET 2002/2003
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 6th, 2005, 05:33 PM
Authorized User
 
Join Date: Aug 2004
Location: dollard des ormeaux, Quebec, Canada.
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to macupryk Send a message via Yahoo to macupryk
Default EXCEL question saving a file saving the the first

in the Button1_Click I need to make the 1st column saved as readonly.

How can I do this?

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.SqlClient;
using System.Xml.Xsl;
using System.Xml;

namespace PDM.excel
{
     /// <summary>
     /// Summary description for WebForm3.
     /// </summary>
     public class WebForm3 : System.Web.UI.Page
     {
          protected System.Web.UI.WebControls.DataGrid DataGrid1;
          public SqlConnection conDB = new SqlConnection();

          static public string[] LanguageStr =
          {
               "English","French","Spanish"};
          static public string[] DropDownListStr =
          {
               "Language_DropDownList"};
          protected System.Web.UI.WebControls.DropDownList Language_DropDownList;
          protected System.Web.UI.WebControls.Label Label1;
          protected System.Web.UI.WebControls.Button Button1;

          static public string[][] AddStrArray =
          {
               LanguageStr};

          private void Fill_DropDownList()
          {
               for (int i = 0; i < DropDownListStr.Length; i++)
               {
                    string CtrlName= DropDownListStr[i];
                    DropDownList MyList = (DropDownList)Page.FindControl(CtrlName);
                    // Populate all the checkboxes
                    string[] ToPopulate = AddStrArray[i];
                    for (int j = 0; j < ToPopulate.Length; j++)
                    {
                         MyList.Items.Add(new ListItem(ToPopulate[j], j.ToString()));
                    }
               }
          }

          private void Page_Load(object sender, System.EventArgs e)
          {
               // Put user code to initialize the page here
               if(!Page.IsPostBack)
               {
                    Fill_DropDownList();


               }

          }

          #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.Language_DropDownList.SelectedIndexChanged += new System.EventHandler(this.Language_DropDownList_Sel ectedIndexChanged);
               this.Button1.Click += new System.EventHandler(this.Button1_Click);
               this.Load += new System.EventHandler(this.Page_Load);

          }
          #endregion

          public DataSet DataToExcel = new DataSet();



          private void Language_DropDownList_SelectedIndexChanged(object sender, System.EventArgs e)
          {
               int getSelectedIndex = Language_DropDownList.SelectedIndex+1;
               conDB.ConnectionString = "data source=10.195.17.7;database=devnew;uid=bounaajak;p wd=ehsfirst;packet size=4096";
               SqlDataAdapter da = new SqlDataAdapter("Select string_id, string from pdm_translations where language_id = 1 and string_id not in (select string_id from pdm_translations where language_id = " + getSelectedIndex.ToString() + ") ", conDB);
               da.Fill(DataToExcel, "DataToExcel");
              Session["Tabla"] = Language_DropDownList.SelectedItem.Text;
               DataToExcel.WriteXml(Server.MapPath(Session["Tabla"] + ".xml"));
               DataGrid1.DataSource = DataToExcel;
               DataGrid1.DataBind();
               Language_DropDownList.Visible = false;

          }

          private void Button1_Click(object sender, System.EventArgs e)
          {
               Response.ContentType = "application/vnd.ms-excel";
               Response.Charset = "";
               DataSet ds = new DataSet();
               ds.ReadXml(Server.MapPath(Session["Tabla"] + ".xml"));
               XmlDataDocument xdd = new XmlDataDocument(ds);
               XslTransform xt = new XslTransform();
               xt.Load(Server.MapPath("Excel.xsl"));
               xt.Transform(xdd, null, Response.OutputStream);
               Response.End();
          }




     }
}


Knowledge is to be shared.
__________________
Knowledge is to be shared.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Question on saving changes to databases PatCiferri SQL Server 2005 1 December 4th, 2007 04:56 PM
Need help AFTER saving an Excel File amerk20 Excel VBA 5 January 8th, 2007 01:42 PM
Saving Excel File tdaustin Classic ASP Basics 6 December 2nd, 2006 03:38 AM
Saving an excel file in Access VBA theboylatham Access VBA 1 August 19th, 2005 08:14 AM
How To avoid the SAving of toolbars while saving Hari_Word Excel VBA 6 July 26th, 2004 12:13 AM



All times are GMT -4. The time now is 04:59 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.