EXCEL question saving a file saving the the first column as read only

Discussion in 'ASP .Net' started by Luis Esteban Valencia, Jan 6, 2005.

  1. 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;
    DropDownList MyList =
    (DropDownList)Page.FindControl(CtrlName);
    // Populate all the checkboxes
    string[] ToPopulate = AddStrArray;
    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_SelectedIndexChanged);
    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;pwd=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();
    }




    }
    }


    --
    LUIS ESTEBAN VALENCIA
    MICROSOFT DCE 3.
    MIEMBRO ACTIVO DE ALIANZADEV
    http://spaces.msn.com/members/extremed/
     
    Luis Esteban Valencia, Jan 6, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. matt
    Replies:
    9
    Views:
    423
    Andrew Thompson
    Oct 27, 2004
  2. keithb
    Replies:
    2
    Views:
    8,020
    keithb
    Jun 7, 2006
  3. Mel

    Open Excel file as read only

    Mel, Nov 14, 2008, in forum: ASP .Net
    Replies:
    3
    Views:
    2,892
  4. Darin Duphorn
    Replies:
    4
    Views:
    119
    Darin Duphorn
    Feb 4, 2008
  5. Greener
    Replies:
    1
    Views:
    113
    Dave Peterson
    Oct 9, 2003
Loading...

Share This Page