Reading csv (pipe delimited) in excel

CalmSoul
CalmSoul used Ask the Experts™
on
I am looking for a script to read c:\text.csv (pipe delimited) in excel and save it as xls

Read data in excel "template.xls" starting from cell A2

How is this possible?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
following code how make it run in C#?
void Read_Excel()

{

// Test.xls is in the C:\

string connectionString = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + C:\Test.xls + ";";

connectionString += "Extended Properties=Excel 8.0;";

// always read from the sheet1.

OleDbCommand myCommand = new OleDbCommand("Select * from [Sheet1$];");

OleDbConnection myConnection = new OleDbConnection(connectionString);

myConnection.Open();

myCommand.Connection = myConnection;

OleDbDataReader myReader = myCommand.ExecuteReader();

while (myReader.Read())

{

// it can read upto 5 columns means A to E. In your case if the requirement is different then change the loop limits a/c to it.

for (int i = 0; i < 5; i++)

{

Response.Write(myReaderIdea.ToString() + " ");

}

Response.Write("<br>");

}

myConnection.Close();

}

Open in new window

Commented:
in this example, they're using the excel provider to treat xls file as a database...

if this is what you want, you can add that provider by going to:
Start -> Settings -> Control Panel -> Administrative Tools -> Data Sources (ODBC) and add a data source
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Calmsoul I answered this on your other ?.  You should really close that one before asking the same ? again.
I'm sorry, you're lookign for C# specifically.  Sorry

Author

Commented:
dimaj:

Can you do sample project for me? I am new to C#

Commented:
It's not exactly my example, but here you go: http://www.codeproject.com/KB/cs/Excel_and_C_.aspx

it demonstrates how to write data to excel using C#

Author

Commented:
good

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial