By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,839 Members | 2,270 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,839 IT Pros & Developers. It's quick & easy.

save a excel file as a tab delimited text file

P: n/a
Hi all
i am trying to save a excel file as a tab delimited text file. can i
do it some how?

i using the code

_sheet1.SaveAs(@"C:\PRP
\PRPTemp.txt",Excel.XlFileFormat.xlTextWindows ,Type.Missing,Type.Missing,Type.Missing,Type.Missi ng,Type.Missing,Type.Missing,Type.Missing);

Kindly assist
regards
shantanu

Jun 15 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Hi Shantanu,

have a look at http://www.codeproject.com/cs/database/CsvReader.asp .
Might help you.

Regards
Rainer

"shantanu" <sh***********@gmail.comschrieb im Newsbeitrag
news:11**********************@e9g2000prf.googlegro ups.com...
Hi all
i am trying to save a excel file as a tab delimited text file. can i
do it some how?

i using the code

_sheet1.SaveAs(@"C:\PRP
\PRPTemp.txt",Excel.XlFileFormat.xlTextWindows
,Type.Missing,Type.Missing,Type.Missing,Type.Missi ng,Type.Missing,Type.Missing,Type.Missing);

Kindly assist
regards
shantanu


Jun 15 '07 #2

P: n/a
On Jun 15, 11:55 am, "Rainer Queck" <Rai...@noemail.noemailwrote:
Hi Shantanu,

have a look athttp://www.codeproject.com/cs/database/CsvReader.asp.
Might help you.

Regards
Rainer

"shantanu" <shantanuse...@gmail.comschrieb im Newsbeitragnews:11**********************@e9g2000pr f.googlegroups.com...
Hi all
i am trying to save a excel file as a tab delimited text file. can i
do it some how?
i using the code
_sheet1.SaveAs(@"C:\PRP
\PRPTemp.txt",Excel.XlFileFormat.xlTextWindows
,Type.Missing,Type.Missing,Type.Missing,Type.Missi ng,Type.Missing,Type.Miss*ing,Type.Missing);
Kindly assist
regards
shantanu- Hide quoted text -

- Show quoted text -
hi thanks
but i have a excel file with two coloumns A and B and i have to write
the coloumn values in two diffrent lines in a text file with tab
delimiters.
regards
shantanu

Jun 15 '07 #3

P: n/a
"shantanu" <sh***********@gmail.comwrote in message
news:11**********************@e9g2000prf.googlegro ups.com...
i am trying to save a excel file as a tab delimited text file. can i
do it some how?

i using the code

_sheet1.SaveAs(@"C:\PRP
\PRPTemp.txt",Excel.XlFileFormat.xlTextWindows
,Type.Missing,Type.Missing,Type.Missing,Type.Missi ng,Type.Missing,Type.Missing,Type.Missing);
Please show your full code...

It looks like you are trying to use server-side Office Automation, which
won't work:
http://support.microsoft.com/default...US;q257757#kb2
--
http://www.markrae.net

Jun 15 '07 #4

P: n/a
On Jun 15, 1:00 pm, "Mark Rae" <m...@markNOSPAMrae.netwrote:
"shantanu" <shantanuse...@gmail.comwrote in message

news:11**********************@e9g2000prf.googlegro ups.com...
i am trying to save a excel file as a tab delimited text file. can i
do it some how?
i using the code
_sheet1.SaveAs(@"C:\PRP
\PRPTemp.txt",Excel.XlFileFormat.xlTextWindows
,Type.Missing,Type.Missing,Type.Missing,Type.Missi ng,Type.Missing,Type.Miss*ing,Type.Missing);

Please show your full code...

It looks like you are trying to use server-side Office Automation, which
won't work:http://support.microsoft.com/default...US;q257757#kb2

--http://www.markrae.net
hi Thanks
here is the code

#region "Open Development Plan Sheet"
private void OpenDPS()
{
try
{
int i;
string[] arrPlanned;
string[] arrMilestone;

int cellloc=0;

Excel.Range testRng, test;
Excel.Range XLSrange,xlsRngPlanned,xlsRngMilestone;
Excel.Range ProjNo,ProjNm;
_book = OpenExcelWorkbook(strXlsFile);
_sheet = (Excel.Worksheet)_book.ActiveSheet;
_sheet.Select(Type.Missing);

Excel.Worksheet _shtOut = (Excel.Worksheet)_book.Worksheets[1];
while(_shtOut.Name != "DevelopmentPlan")
{
_shtOut = (Excel.Worksheet)_shtOut.Next;
}

XLSrange = _shtOut.UsedRange;

ReadPRPTemp();

arrPlanned = new string[arrHeader.Length];

for (i = 16 ; i <= XLSrange.Rows.Count ; i++)
{
xlsRngPlanned = _shtOut.get_Range("C" +
i.ToString(),Type.Missing);
if(xlsRngPlanned.Value!=null)
{
arrPlanned[i]= xlsRngPlanned.Value.ToString();
}
else
{
arrPlanned[i] = "";
}
}

arrMilestone = new string[arrHeader.Length];

TextWriter t = new StreamWriter(@"C:\PRP\PRPTemp.xls");
foreach(string s in arrHeader)
{
t.Write(s.ToUpper() + "\t");
}
t.Close();

for (int l = 16 ; l <= XLSrange.Rows.Count-1 ; l++)
{
xlsRngMilestone = _shtOut.get_Range("B" +
l.ToString(),Type.Missing);
if(xlsRngMilestone.Value!=null)
{
arrMilestone[l] = xlsRngMilestone.Value.ToString() +
".PLANNED";
}
else
{
break;
}
}
ProjNo = _shtOut.get_Range("H6",Type.Missing);
ProjNm = _shtOut.get_Range("H7",Type.Missing);

_book1 = OpenExcelWorkbook(@"C:\PRP\PRPTemp.xls");
_sheet1 = (Excel.Worksheet)_book1.ActiveSheet;
_sheet1.Select(Type.Missing);

TextWriter twr = new StreamWriter(@"C:\WINDOWS\Temp
\PRPLogin.txt");
twr.WriteLine("1");
twr.Close();

Excel.Worksheet _shtOut1 = (Excel.Worksheet)_book1.Worksheets[1];
testRng = _shtOut1.UsedRange;

_shtOut1.get_Range("A2",Type.Missing).Value = ProjNo.Value;
_shtOut1.get_Range("B2",Type.Missing).Value = ProjNm.Value;

//MessageBox.Show(testRng.Columns.h);
for(int x = 1;x<= testRng.rows.Count; x++)
{
test = _shtOut1.get_Range("A" + x.ToString(),Type.Missing);
if(test.Value!=null)
{
for (int l = 16 ; l <= XLSrange.Rows.Count-1 ; l++)
{
xlsRngMilestone = _shtOut.get_Range("B" +
l.ToString(),Type.Missing);
xlsRngPlanned = _shtOut.get_Range("C" +
l.ToString(),Type.Missing);
if(xlsRngMilestone.Value!=null)
{
if(test.Value.ToString() == xlsRngMilestone.Value.ToString() +
".PLANNED" )
{
cellloc = x;
_shtOut1.get_Range("B" + x.ToString() , Type.Missing).Value =
xlsRngPlanned.Value;
}
}
else
{
break;
}
}
}
}

_book1.Save();
_sheet1.SaveAs(@"C:\PRP
\PRPTemp.txt",Excel.XlFileFormat.xlTextWindows,Typ e.Missing,Type.Missing,Type.Missing,Type.Missing,T ype.Missing,Type.Missing,Type.Missing);

_sheet1 = null;
NAR(_sheet1);
ExcelApp.ActiveWindow.Close(false,@"C:\PRP\PRPTemp .xls",false);
}
catch(Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
#endregion

Jun 15 '07 #5

P: n/a
"shantanu" <sh***********@gmail.comwrote in message
news:11**********************@q19g2000prn.googlegr oups.com...
>Please show your full code...

It looks like you are trying to use server-side Office Automation, which
won't
work:http://support.microsoft.com/default...US;q257757#kb2

here is the code
Excel.Range testRng, test;
_book = OpenExcelWorkbook(strXlsFile);
_sheet = (Excel.Worksheet)_book.ActiveSheet;
_sheet.Select(Type.Missing);
As I suspected, this is server-side Office Automation which won't work:
http://support.microsoft.com/default...US;q257757#kb2

Fetch the data from the worksheet using ADO.NET:
http://www.google.co.uk/search?sourc...22ADO%2eNET%22
--
http://www.markrae.net

Jun 15 '07 #6

P: n/a
On Jun 15, 1:59 pm, "Mark Rae" <m...@markNOSPAMrae.netwrote:
"shantanu" <shantanuse...@gmail.comwrote in message

news:11**********************@q19g2000prn.googlegr oups.com...
Please show your full code...
It looks like you are trying to use server-side Office Automation, which
won't
work:http://support.microsoft.com/default...US;q257757#kb2
here is the code
Excel.Range testRng, test;
_book = OpenExcelWorkbook(strXlsFile);
_sheet = (Excel.Worksheet)_book.ActiveSheet;
_sheet.Select(Type.Missing);

As I suspected, this is server-side Office Automation which won't work:http://support.microsoft.com/default...US;q257757#kb2

Fetch the data from the worksheet using ADO.NET:http://www.google.co.uk/search?sourc...hl=en-GB&ie=UT...

--http://www.markrae.net
hi
But how i am going to put it again in a text file in tab delimited
format
regards
shantanu

Jun 15 '07 #7

P: n/a
"shantanu" <sh***********@gmail.comwrote in message
news:11**********************@i38g2000prf.googlegr oups.com...
But how i am going to put it again in a text file in tab delimited
format
1) Fetch the data from Excel using ADO.NET into a DataSet or maybe an
OleDbDataReader

2) Instantiate a TextWriter object

3) Iterate through the rows of the data object

4) For each row, write a line to the TextWriter object

MyTextWriter.WriteLine(<RowObject>[0].ToString() + "\t" +
<RowObject>[1].ToString());
--
http://www.markrae.net

Jun 15 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.