473,799 Members | 3,121 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# and EXCEL question saving a file saving the the first column as read only



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

How can I do this?

using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.Sess ionState;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;
using System.Data.Sql Client;
using System.Xml.Xsl;
using System.Xml;

namespace PDM.excel
{
/// <summary>
/// Summary description for WebForm3.
/// </summary>
public class WebForm3 : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Data Grid DataGrid1;
public SqlConnection conDB = new SqlConnection() ;

static public string[] LanguageStr =
{
"English","Fren ch","Spanish" };
static public string[] DropDownListStr =
{
"Language_DropD ownList"};
protected System.Web.UI.W ebControls.Drop DownList
Language_DropDo wnList;
protected System.Web.UI.W ebControls.Labe l Label1;
protected System.Web.UI.W ebControls.Butt on Button1;

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

private void Fill_DropDownLi st()
{
for (int i = 0; i < DropDownListStr .Length; i++)
{
string CtrlName= DropDownListStr[i];
DropDownList MyList =
(DropDownList)P age.FindControl (CtrlName);
// Populate all the checkboxes
string[] ToPopulate = AddStrArray[i];
for (int j = 0; j < ToPopulate.Leng th; j++)
{
MyList.Items.Ad d(new ListItem(ToPopu late[j],
j.ToString()));
}
}
}

private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
if(!Page.IsPost Back)
{
Fill_DropDownLi st();
}

}

#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form
Designer.
//
InitializeCompo nent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.Language_D ropDownList.Sel ectedIndexChang ed += new
System.EventHan dler(this.Langu age_DropDownLis t_SelectedIndex Changed);
this.Button1.Cl ick += new
System.EventHan dler(this.Butto n1_Click);
this.Load += new System.EventHan dler(this.Page_ Load);

}
#endregion

public DataSet DataToExcel = new DataSet();

private void Language_DropDo wnList_Selected IndexChanged(ob ject
sender, System.EventArg s e)
{
int getSelectedInde x =
Language_DropDo wnList.Selected Index+1;
conDB.Connectio nString = "data
source=10.195.1 7.7;database=de vnew;uid=bounaa jak;pwd=ehsfirs t;packet
size=4096";
SqlDataAdapter da = new SqlDataAdapter( "Select string_id,
string from pdm_translation s where language_id = 1 and string_id not in
(select string_id from pdm_translation s where language_id = " +
getSelectedInde x.ToString() + ") ", conDB);
da.Fill(DataToE xcel, "DataToExce l");
Session["Tabla"] =
Language_DropDo wnList.Selected Item.Text;
DataToExcel.Wri teXml(Server.Ma pPath(Session["Tabla"] +
".xml"));
DataGrid1.DataS ource = DataToExcel;
DataGrid1.DataB ind();
Language_DropDo wnList.Visible = false;

}

private void Button1_Click(o bject sender, System.EventArg s e)
{
Response.Conten tType = "applicatio n/vnd.ms-excel";
Response.Charse t = "";
DataSet ds = new DataSet();
ds.ReadXml(Serv er.MapPath(Sess ion["Tabla"] + ".xml"));
XmlDataDocument xdd = new XmlDataDocument (ds);
XslTransform xt = new XslTransform();
xt.Load(Server. MapPath("Excel. xsl"));
xt.Transform(xd d, null, Response.Output Stream);
Response.End();
}


}
}
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #1
0 1308

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
6692
by: Daniel Chartier | last post by:
Hello, all. I found a bit of code that lets me read an Excel file from and to a specifi range. See the code below. But what if I only want to specify the STARTING position and simply want it to continue reading down the column until it hits an empty cell? Does anyone know how to do this? Thanks! Here is the range-only code:
4
11313
by: RK | last post by:
Hi, In my application, I need to copy data from an Excel file into a SQL table. The article related to this can be found at http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B306572 Using this,I am first extracting data from given excel file into a temporary DataTable. After making some operations on that DataTable (like splitting one column into two), I am saving the data into actual
0
4704
by: Peter | last post by:
I am having a problem reading an Excel file that is XML based. The directory I am reading contains Excel files that can be of two types. Either generic Microsoft based or XML based. I am reading the Microsoft based files with an OleDbDataAdapter. Then filling the contents of the first worksheet into a dataset. However when I try to add the XML based file to my dataset using an XmlTextReader I can never seem to get it to save to a...
4
3305
by: dale zhang | last post by:
Hi, I am trying to save and read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp Right now, I saved images without any errors. After reading the ole object from db, I saved it to C: as file1.bmp and displayed on the web. But it can not be displayed. After I manually sent the file to wordpad, it shows
0
1159
by: Luis Esteban Valencia | last post by:
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;
5
8958
by: Scott M. Lyon | last post by:
I've just discovered a bug in some code I wrote a little while ago, and I need you guys' help to fix it. My program imports data from a standard Excel Spreadsheet (just with specific column headers). I used ODBC in my VB.NET program to read that spreadsheet into a dataset, to make it easy to manipulate. The code I use to read it is as the bottom of this posting.
2
3124
by: Mad Scientist Jr | last post by:
>From an asp.net web page I want the user to open the results of a SQL query in Excel, as automatically as possible (ie not having to loop through columns, rows, in code). For this, dataset.writexml works great (got the code from http://forums.devx.com/archive/index.php/t-57273.html ) The only question I have is, when Excel opens up, it isn't the view I would prefer. It opens as a read-only workbook, I would prefer as an
1
9779
by: smaczylo | last post by:
Hello, I've recently been asked to work with Microsoft Access, and while I feel quite comfortable with Excel, I'm at a complete loss with databases. If someone could help me with this issue I'm having I'd be most appreciative. The database is already constructed, I'm just wanting to export the data to an excel file. In short, I'm hoping to export two Tables (or queries...not sure which to use - they both seem to have the same data) in...
7
12077
by: TG | last post by:
hi! I am trying to create a sql server table from an excel sheet. Here is the code I have: 'This procedure the xlsx file and dumps it to a table in SQL Server
0
9541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10482
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10225
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9072
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7564
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4139
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.