I already have attributes in the app settings part of the file. For these particular att. I need to extract their values and put them into an array. The number of attributes is not static so I cannot place them in an array using their keys. Is there any other way???.
sean_mufc
Posts
-
extract info from XML config files -
extract info from XML config filesHi all, I am looking to extract data from an xml config file and place the values in an array. Extract:- .... .... I need to take the values an place in an array. So far I cannot even figure out how to acees the data in the section of the config file. Any ideas??? Seán
-
extract info from XML config filesHi all, I am looking to extract data from an xml config file and place the values in an array. Extract:- .... .... I need to take the values an place in an array. So far I cannot even figure out how to acees the data in the section of the config file. Any ideas??? Seán -- modified at 8:28 Thursday 11th May, 2006
-
Open Excel ProjectI had a big headache trying to do this myself. There may be a way to read and write to a file, but I found I a diffent way to write to Excel, and a different was of reading from, with some help from one of our friends on the CodeProject. Here is a simple example of writing to Excel. It creates a new Excel book and writes a string in the 1st cell. /**************************************************/ using System; using Excel; using System.IO; using System.Text; using System.Data.OleDb; namespace Writing_to_Excel_example { class Class1 { static void Main(string[] args) { bool xlsError = false; int rowCount = 0; int counter = 0; int counter2 = 0; Console.WriteLine("Working..."); Excel.Application ExcelObj = new Excel.Application(); Excel.Workbook workbook = ExcelObj.Workbooks.Add(Type.Missing); if (ExcelObj == null) { Console.WriteLine("\nERROR: EXCEL couldn't be started!"); xlsError = true; } // activate the active worksheet in the workbook Worksheet ws = (Worksheet)ExcelObj.ActiveSheet; ws.Activate(); try { //To enter text to a specific row and column: ((Range)ws.Cells[1, 1]).Value2 = ("This is Row 1, Column 1"); //To set an entire row as Bold. ((Range)ws.Cells[rowCount, 1]).EntireRow.Font.Bold = true; }//end try catch(Exception e) { Console.Write(e); } //Make Excel visible. ExcelObj.Visible = true; } } } /***************************************************************/ DONT FORGET TO ADD REFERENCE TO EXCEL 11.0 OBJECT LIBRARY!! As for reading from excel, I tried to apply the same sort of logic as above but it didn't work. So have a look at this link: http://www.codeproject.com/csharp/FasterExcelAccessTOC.asp[^] Great tips there, a great help to me, Thanks to Dusty Candland, great help mate!! t-seanm
-
Error creating .exeHello, I am trying to write a simple console app that reads the data contained in specific Excel spreadsheet cells, and use that data to write an .xml file with the XmlTextWriter class. when I go to compile the code, I get an error that says it does not recognise 'using Excel;' and that I may be missing a reference. The thing is I had already added the Excel reference from the Project > Add Reference.. dialog. I run into this error before when writing to an Excel worksheet and after I clicked 'Yes' to continue in the 'Build Errors' dialog, the app ran perfectly, but not this time. I now get an error that says VS cannot start debugging beacuse the debug target \Program.exe is missing. I have never seen this before, can anyone help me? The code below is an extract on my class: class Program { static void Main(string[] args) { //directory of XLS file to be read from string xlsDir = ""; bool xlsError = false; XmlTextWriter writer = new XmlTextWriter("C:\\My Documents\\test1.xml", _UnicodeEncoding); writer.Formatting = Formatting.Indented; int countVPS = 0; //to increment the VPSnodes array string[] VPSnodes = new string[5] { vendorID, vendor, copyright, version, _schemaVersion }; //opens dialog to browse directories and open a file OpenFileDialog openFile = new OpenFileDialog(); openFile.InitialDirectory = "c:\\My Documents"; openFile.Filter = "xls files (*.xls)|*.xls*|xml files (*.xml)*.xml*| _All files (*.*)|*.*"; if (openFile.ShowDialog() == DialogResult.OK) { xlsDir = openFile.FileName; Excel.Workbook wb = this.Application.Workbooks.Open(xlsDir); // activate the active worksheet in the workbook (Microsoft.Office.Interop.Excel._Workbook) _this.Application.Workbooks[1]).Activate(); ((Excel.Worksheet)this.Application.ActiveWorkbook.ActiveSheet); try { if (ExcelObj == null) { Console.WriteLine("\nERROR: EXCEL couldn't be started!"); xlsError = true; } if (xlsError == false) { writer.WriteRaw(""); writer.WriteStartElement("vendorProductSet"); for (int colV = 1; colV <= 5; colV++) { writer.WriteAttributeString(nodes[countVPS], _((Range)ws.Cells[2, col]).Value2); countVPS++;
-
Error While opening a Dot net ProjectI've never encountered this before but you can try to open the class that is causing the problem with a text editor (recommend CrimsonEditor as it color codes c#, vb, j# etc..) and have a look at the code yourself to try and determine the problem. Thats the only thing I can suggest. Sorry I couldn't be more help!
-
Nightmare!!!I am writing a simple tool that extracts data from an xls and uses it to write an XML file using the XmlTextWriter class. I have a test harness written, problem is I keep getting the following error: "VS cannot debugging the target as the ....exe is missing. Please build the project and retry, or set the OutputPath and AssemblyName properties appropriately to point at the correct location for the target assembly." I have added the reference "Excel 11.0" so that isn't the problem. I am using a file dialog and have added the "System.Windows.Forms" reference so there is no problem there. Has anyone ever had this problem beofre when dealing with Excel or XmlTextWriter?
-
a beginerWell to tell u the truth the only reason I took up .Net is I am currently an intern in Microsoft Ireland. But there are so many advantages... The excellent help section that comes with Visual Studio and online, not to mention the code samples. The Microsoft press release contains tonnes of book for helping developers do just about anything. You have to pop-up menus that appear each time you use dot notation, telling you what methods are available to you. I always wanted to learn to use ASP.NET and with talking to people here at MS Ireland, c# or VB are the languages of choice for ASP.NET applications. Since c# is similar to Java, I chose it over the other languages. I picked it up quite easily, and i've never been a fan of VB, the syntax annoys me for some reason.
-
a beginerThe is no difinitive answer to that question. I work with c# because my background experience is in Java, and the similarities made it easy to migrate from Java to c#. Also most of the readily available books on writing Windows apps. and asp.net web form's are orientated around c# and VB, although i'm sure it is easy to get hold of books orientated around c++. The beauty of Visual Studio.net is that all the language's have more or less the same level of functionality. Check out http://msdn.microsoft.com/vstudio/productinfo/topten/upgrade.aspx
-
Timer ObjectI am assuming you are writing a Windows App. Basically you click on the timer in the Toolbox panel (in design view) and drag it to the form. Go to timer properties an set Enabled to True and Interval to 1000ms (1s). Double click on the timer icon in design view, This will then switch to your code and it will have added the following: private void timer1_Tick(object sender, System.EventArgs e) { // forech loop and associated code to go here } Put your code inside the method and it will run ever second
-
Reading Text FilesSounds as if you have a simple problem, but cannot be sure as you haven't posyed your code. Try using the ToString() method, contained within most classes in the .NET Framework
-
Plz help .. its urgent...if your LinkButton is called LinkButton1: private void LinkButton1_Click(object sender, System.EventArgs e) { Response.Redirect("Form2.aspx"); }
-
Plz help .. its urgent...i can send you an e-book on Developing web applications. It is published by Microsoft specifically for ASP.NET web applications. You can get all the info you need in it! Problem is, it is about 4.5MB. Does your ISP allow you to receive emails that size???
-
Directory ParsingHello i'm having a problem with the following code fragment: //---------------------------------------------------------------------- //loop through each sub directory in the current dir //and look for each folders contained in folders array foreach(DirectoryInfo subDir in dirs) { //this line eliminates an IO error, although I dont know why it is an error if (subDir.ToString().Equals("System Volume Information")) Console.WriteLine(); else { for (int i =0; i < 7; i++) { currentFolder = folders[i]; if (subDir.Exists)//make sure directory exists { subDir.GetDirectories("*" + currentFolder + "*"); Console.WriteLine(subDir.ToString()); subDir.Equals(null); } //end if } //end for }//end else }//end foreach //recursive statements DirectoryInfo[] subDirs = dirInfo.GetDirectories(); for (int i = 0; i < subDirs.Length; i++) { String dirName = subDirs[i].FullName.ToString(); findFolders(dirName); } }//end method //--------------------------------------------------------------------- Basically it should search the directory hierarchy and ouput to the console the names of the directories that match search criteria contained in the array []folders. Problem is it returns the entire directory hierarchy!! CAN ANYONE HELP ME!!!!