Click here to Skip to main content
15,921,113 members
Home / Discussions / C#
   

C#

 
GeneralRe: how to get System Root of Virtual Directory Pin
KSCsoft20-Jun-06 20:26
KSCsoft20-Jun-06 20:26 
GeneralRe: how to get System Root of Virtual Directory Pin
Edbert P20-Jun-06 20:40
Edbert P20-Jun-06 20:40 
QuestionProblem formatting while retrieving string in xml document Pin
ashishinfra20-Jun-06 19:49
ashishinfra20-Jun-06 19:49 
QuestionConvert Form to dll Pin
freshonlineMax20-Jun-06 19:29
freshonlineMax20-Jun-06 19:29 
AnswerRe: Convert Form to dll Pin
Christian Graus20-Jun-06 19:43
protectorChristian Graus20-Jun-06 19:43 
AnswerRe: Convert Form to dll Pin
KSCsoft20-Jun-06 20:38
KSCsoft20-Jun-06 20:38 
QuestionColumn Separator Text File Pin
satsumatable20-Jun-06 19:28
satsumatable20-Jun-06 19:28 
AnswerRe: Column Separator Text File Pin
ashishinfra20-Jun-06 20:02
ashishinfra20-Jun-06 20:02 
I think , first you can import this to datagrid and there are lots of articles which can help you to export to excel ..

following is the code snippet that may solve your problem

step 1 include this class to read read the value from text file
public class TextToDataSet
//created by ashish gupta on 12/5/2005 for log register
	{
		public TextToDataSet()
		{
			//
			// TODO: Add constructor logic here
			//
		}

		public static DataSet Convert(string File, 
			string TableName, string delimiter)
		{   
			//The DataSet to Return
			DataSet result = new DataSet();
    
			//Open the file in a stream reader.
			StreamReader s = new StreamReader(File);
        
			//Split the first line into the columns       
			string[] columns = s.ReadLine().Split(delimiter.ToCharArray());
  
			//Add the new DataTable to the RecordSet
			result.Tables.Add(TableName);
    
			//Cycle the colums, adding those that don't exist yet 
			//and sequencing the one that do.
			foreach(string col in columns)
			{
				bool added = false;
				string next = "";
				int i = 0;
				while(!added)        
				{
					//Build the column name and remove any unwanted characters.
					string columnname = col + next;
					columnname = columnname.Replace("#","");
					columnname = columnname.Replace("'","");
					columnname = columnname.Replace("&","");
        
					//See if the column already exists
					if(!result.Tables[TableName].Columns.Contains(columnname))
					{
						//if it doesn't then we add it here and mark it as added
						result.Tables[TableName].Columns.Add(columnname);
						added = true;
					}
					else
					{
						//if it did exist then we increment the sequencer and try again.
						i++;  
						next = "_" + i.ToString();
					}         
				}
			}
    
			//Read the rest of the data in the file.        
			string AllData = s.ReadToEnd();
    
			//Split off each row at the Carriage Return/Line Feed
			//Default line ending in most windows exports.  
			//You may have to edit this to match your particular file.
			//This will work for Excel, Access, etc. default exports.
			string[] rows = AllData.Split("\r\n".ToCharArray());
 
			//Now add each row to the DataSet        
			foreach(string r in rows)
			{
				//Split the row at the delimiter.
				string[] items = r.Split(delimiter.ToCharArray());
      
				//Add the item
				result.Tables[TableName].Rows.Add(items);  
			}
    
			//Return the imported data.        
			return result;
		}
	}



step 2
fill the contents of the text file to the dataset using following syntax

DataSet dsupdate = TextToDataSet.Convert(System.Web.HttpContext.Current.Server.MapPath("./LogFiles/ErrLog.txt"),"errorhandlerlog","$");

here convert is the static method of the class

Now 50 % of work is over you can either bind the dataset to the datagrid and refer other articles on code project which are on exporting dataset to excel or datagrid to excel . Exporting the text file directly to excel may not help when you want to debug or in case of some unknown error.

Hope this give you litte comfort for your problemSmile | :)
Questionhow to convert ms access query to sql query Pin
leelaraj20-Jun-06 17:55
leelaraj20-Jun-06 17:55 
AnswerRe: how to convert ms access query to sql query Pin
Guffa20-Jun-06 18:52
Guffa20-Jun-06 18:52 
GeneralRe: how to convert ms access query to sql query Pin
leelaraj20-Jun-06 19:25
leelaraj20-Jun-06 19:25 
AnswerRe: how to convert ms access query to sql query Pin
Guffa21-Jun-06 11:37
Guffa21-Jun-06 11:37 
GeneralRe: how to convert ms access query to sql query Pin
leelaraj22-Jun-06 19:42
leelaraj22-Jun-06 19:42 
Questionhow can i run an application with parameters ? [modified] Pin
abiisalwayshappy20-Jun-06 17:17
abiisalwayshappy20-Jun-06 17:17 
AnswerRe: how can i run an application with parameters ? [modified] Pin
Guffa20-Jun-06 18:42
Guffa20-Jun-06 18:42 
Questionwindows application Pin
skyeddie20-Jun-06 16:59
skyeddie20-Jun-06 16:59 
AnswerRe: windows application Pin
led mike20-Jun-06 19:45
led mike20-Jun-06 19:45 
GeneralRe: windows application Pin
skyeddie20-Jun-06 21:52
skyeddie20-Jun-06 21:52 
GeneralRe: windows application Pin
led mike21-Jun-06 5:11
led mike21-Jun-06 5:11 
QuestionRe: windows application?? Pin
skyeddie20-Jun-06 21:55
skyeddie20-Jun-06 21:55 
AnswerRe: windows application Pin
KSCsoft20-Jun-06 20:19
KSCsoft20-Jun-06 20:19 
QuestionListView Paint Events Pin
Tyrus18220-Jun-06 16:21
Tyrus18220-Jun-06 16:21 
AnswerRe: ListView Paint Events Pin
led mike20-Jun-06 19:37
led mike20-Jun-06 19:37 
QuestionSQL Update isn't working, not sure how to fix it. Pin
PyroManiak20-Jun-06 15:18
PyroManiak20-Jun-06 15:18 
AnswerRe: SQL Update isn't working, not sure how to fix it. Pin
PyroManiak21-Jun-06 8:33
PyroManiak21-Jun-06 8:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.