PC Review


Reply
Thread Tools Rate Thread

Convert .CSV format to .XLS format in C#

 
 
=?Utf-8?B?TGl5YWtoYXQ=?=
Guest
Posts: n/a
 
      16th Jul 2007
Hi all,

My CSV file Contains Data like.
-----------------------------------

Ex: DriverID | CustomerID | Ship to ID | Load # | BOL Date/TimeStamp |
ProductN
520 | 2355 - | 1 | 61953 | ############ | 1 Eth 87

My XLS file Contains Data Like.
------------------------------------------------------------------------------------
Ex: Field Definition Length Starting Column Ending Column

TransType Some Definition 1 1 1
Termin ID Some Difinition 3 3 5
Term SPLC Some Difi 7 6 12

I got the Sorce code from net to Convert the .CSV file to .XLS file(but the
Problem is converted .XLS file is not in specified format, it should be like
above XLS file).


Source CodeConvert .CSV file to .XLS file )


using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using Microsoft.Office.Interop.Excel;

namespace File_Conversion
{
class Program
{
static void Main(string[] args)
{
ApplicationClass app = new ApplicationClass();
Workbook doc = app.Workbooks._Open(
@"C:\GCProject\Input
Example.csv",
Missing.Value,
Missing.Value,
Missing.Value,
Missing.Value,
Missing.Value,
Missing.Value,
Missing.Value,
Missing.Value,
false,
Missing.Value,
Missing.Value,
false);
Console.WriteLine("Reading
CSV File........");
doc.SaveAs(
@"C:\GCProject\Output.xls",
XlFileFormat.xlWorkbookNormal,
Missing.Value,
Missing.Value,
Missing.Value,
Missing.Value,

XlSaveAsAccessMode.xlExclusive,
Missing.Value,
false,
Missing.Value,
Missing.Value,
Missing.Value);
doc.Saved = true;
Console.WriteLine("Converted
CSV to XLS file");
app.Quit();
Console.ReadLine();


}
}
}

Any body have IDEA ?

Thanks in advance,

Regards,
Liyakhat.


 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      16th Jul 2007
I imported your data into excel recording a macro. Here is the code I got.
I used delimited and set a special delimiter character | to match your data.


Sub Macro1()
'
' Macro1 Macro
' Macro recorded 7/16/2007
'
'
With ActiveSheet.QueryTables.Add(Connection:="TEXT;C:\TEMP\test.txt", _
Destination:=Range("A1"))
.Name = "test"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileOtherDelimiter = "|"
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Columns("E:E").ColumnWidth = 26.57
Range("E3").Select
End Sub

"Liyakhat" wrote:

> Hi all,
>
> My CSV file Contains Data like.
> -----------------------------------
>
> Ex: DriverID | CustomerID | Ship to ID | Load # | BOL Date/TimeStamp |
> ProductN
> 520 | 2355 - | 1 | 61953 | ############ | 1 Eth 87
>
> My XLS file Contains Data Like.
> ------------------------------------------------------------------------------------
> Ex: Field Definition Length Starting Column Ending Column
>
> TransType Some Definition 1 1 1
> Termin ID Some Difinition 3 3 5
> Term SPLC Some Difi 7 6 12
>
> I got the Sorce code from net to Convert the .CSV file to .XLS file(but the
> Problem is converted .XLS file is not in specified format, it should be like
> above XLS file).
>
>
> Source CodeConvert .CSV file to .XLS file )
>
>
> using System;
> using System.Collections.Generic;
> using System.Text;
> using System.Reflection;
> using Microsoft.Office.Interop.Excel;
>
> namespace File_Conversion
> {
> class Program
> {
> static void Main(string[] args)
> {
> ApplicationClass app = new ApplicationClass();
> Workbook doc = app.Workbooks._Open(
> @"C:\GCProject\Input
> Example.csv",
> Missing.Value,
> Missing.Value,
> Missing.Value,
> Missing.Value,
> Missing.Value,
> Missing.Value,
> Missing.Value,
> Missing.Value,
> false,
> Missing.Value,
> Missing.Value,
> false);
> Console.WriteLine("Reading
> CSV File........");
> doc.SaveAs(
> @"C:\GCProject\Output.xls",
> XlFileFormat.xlWorkbookNormal,
> Missing.Value,
> Missing.Value,
> Missing.Value,
> Missing.Value,
>
> XlSaveAsAccessMode.xlExclusive,
> Missing.Value,
> false,
> Missing.Value,
> Missing.Value,
> Missing.Value);
> doc.Saved = true;
> Console.WriteLine("Converted
> CSV to XLS file");
> app.Quit();
> Console.ReadLine();
>
>
> }
> }
> }
>
> Any body have IDEA ?
>
> Thanks in advance,
>
> Regards,
> Liyakhat.
>
>

 
Reply With Quote
 
NickHK
Guest
Posts: n/a
 
      16th Jul 2007
Considering there does not seem to be any correlation between the csv data
and the desired Excel format, it's not possible to advise.
Maybe a query in an Excel WB, so you can use SQL to control the order of the
columns.

NickHK

"Liyakhat" <(E-Mail Removed)> wrote in message
news:4CB88FE3-424E-4ABA-9FF9-(E-Mail Removed)...
> Hi all,
>
> My CSV file Contains Data like.
> -----------------------------------
>
> Ex: DriverID | CustomerID | Ship to ID | Load # | BOL Date/TimeStamp |
> ProductN
> 520 | 2355 - | 1 | 61953 | ############ | 1 Eth 87
>
> My XLS file Contains Data Like.
> --------------------------------------------------------------------------

----------
> Ex: Field Definition Length Starting Column Ending Column
>
> TransType Some Definition 1 1 1
> Termin ID Some Difinition 3 3 5
> Term SPLC Some Difi 7 6 12
>
> I got the Sorce code from net to Convert the .CSV file to .XLS file(but

the
> Problem is converted .XLS file is not in specified format, it should be

like
> above XLS file).
>
>
> Source CodeConvert .CSV file to .XLS file )
>
>
> using System;
> using System.Collections.Generic;
> using System.Text;
> using System.Reflection;
> using Microsoft.Office.Interop.Excel;
>
> namespace File_Conversion
> {
> class Program
> {
> static void Main(string[] args)
> {
> ApplicationClass app = new ApplicationClass();
> Workbook doc = app.Workbooks._Open(
> @"C:\GCProject\Input
> Example.csv",
> Missing.Value,
> Missing.Value,
> Missing.Value,
> Missing.Value,
> Missing.Value,
> Missing.Value,
> Missing.Value,
> Missing.Value,
> false,
> Missing.Value,
> Missing.Value,
> false);
> Console.WriteLine("Reading
> CSV File........");
> doc.SaveAs(
> @"C:\GCProject\Output.xls",
> XlFileFormat.xlWorkbookNormal,
> Missing.Value,
> Missing.Value,
> Missing.Value,
> Missing.Value,
>
> XlSaveAsAccessMode.xlExclusive,
> Missing.Value,
> false,
> Missing.Value,
> Missing.Value,
> Missing.Value);
> doc.Saved = true;
> Console.WriteLine("Converted
> CSV to XLS file");
> app.Quit();
> Console.ReadLine();
>
>
> }
> }
> }
>
> Any body have IDEA ?
>
> Thanks in advance,
>
> Regards,
> Liyakhat.
>
>



 
Reply With Quote
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      16th Jul 2007
This is not CSV (commar seperate values) data. The data is delimited using
the | character.

"NickHK" wrote:

> Considering there does not seem to be any correlation between the csv data
> and the desired Excel format, it's not possible to advise.
> Maybe a query in an Excel WB, so you can use SQL to control the order of the
> columns.
>
> NickHK
>
> "Liyakhat" <(E-Mail Removed)> wrote in message
> news:4CB88FE3-424E-4ABA-9FF9-(E-Mail Removed)...
> > Hi all,
> >
> > My CSV file Contains Data like.
> > -----------------------------------
> >
> > Ex: DriverID | CustomerID | Ship to ID | Load # | BOL Date/TimeStamp |
> > ProductN
> > 520 | 2355 - | 1 | 61953 | ############ | 1 Eth 87
> >
> > My XLS file Contains Data Like.
> > --------------------------------------------------------------------------

> ----------
> > Ex: Field Definition Length Starting Column Ending Column
> >
> > TransType Some Definition 1 1 1
> > Termin ID Some Difinition 3 3 5
> > Term SPLC Some Difi 7 6 12
> >
> > I got the Sorce code from net to Convert the .CSV file to .XLS file(but

> the
> > Problem is converted .XLS file is not in specified format, it should be

> like
> > above XLS file).
> >
> >
> > Source CodeConvert .CSV file to .XLS file )
> >
> >
> > using System;
> > using System.Collections.Generic;
> > using System.Text;
> > using System.Reflection;
> > using Microsoft.Office.Interop.Excel;
> >
> > namespace File_Conversion
> > {
> > class Program
> > {
> > static void Main(string[] args)
> > {
> > ApplicationClass app = new ApplicationClass();
> > Workbook doc = app.Workbooks._Open(
> > @"C:\GCProject\Input
> > Example.csv",
> > Missing.Value,
> > Missing.Value,
> > Missing.Value,
> > Missing.Value,
> > Missing.Value,
> > Missing.Value,
> > Missing.Value,
> > Missing.Value,
> > false,
> > Missing.Value,
> > Missing.Value,
> > false);
> > Console.WriteLine("Reading
> > CSV File........");
> > doc.SaveAs(
> > @"C:\GCProject\Output.xls",
> > XlFileFormat.xlWorkbookNormal,
> > Missing.Value,
> > Missing.Value,
> > Missing.Value,
> > Missing.Value,
> >
> > XlSaveAsAccessMode.xlExclusive,
> > Missing.Value,
> > false,
> > Missing.Value,
> > Missing.Value,
> > Missing.Value);
> > doc.Saved = true;
> > Console.WriteLine("Converted
> > CSV to XLS file");
> > app.Quit();
> > Console.ReadLine();
> >
> >
> > }
> > }
> > }
> >
> > Any body have IDEA ?
> >
> > Thanks in advance,
> >
> > Regards,
> > Liyakhat.
> >
> >

>
>
>

 
Reply With Quote
 
=?Utf-8?B?TGl5YWtoYXQ=?=
Guest
Posts: n/a
 
      16th Jul 2007
Hi Joel,

But how it is usfull in converting .csv file to .xls file. ?

Thanks,
Liyakhat

"Joel" wrote:

> I imported your data into excel recording a macro. Here is the code I got.
> I used delimited and set a special delimiter character | to match your data.
>
>
> Sub Macro1()
> '
> ' Macro1 Macro
> ' Macro recorded 7/16/2007
> '
> '
> With ActiveSheet.QueryTables.Add(Connection:="TEXT;C:\TEMP\test.txt", _
> Destination:=Range("A1"))
> .Name = "test"
> .FieldNames = True
> .RowNumbers = False
> .FillAdjacentFormulas = False
> .PreserveFormatting = True
> .RefreshOnFileOpen = False
> .RefreshStyle = xlInsertDeleteCells
> .SavePassword = False
> .SaveData = True
> .AdjustColumnWidth = True
> .RefreshPeriod = 0
> .TextFilePromptOnRefresh = False
> .TextFilePlatform = 437
> .TextFileStartRow = 1
> .TextFileParseType = xlDelimited
> .TextFileTextQualifier = xlTextQualifierDoubleQuote
> .TextFileConsecutiveDelimiter = False
> .TextFileTabDelimiter = False
> .TextFileSemicolonDelimiter = False
> .TextFileCommaDelimiter = False
> .TextFileSpaceDelimiter = False
> .TextFileOtherDelimiter = "|"
> .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1)
> .TextFileTrailingMinusNumbers = True
> .Refresh BackgroundQuery:=False
> End With
> Columns("E:E").ColumnWidth = 26.57
> Range("E3").Select
> End Sub
>
> "Liyakhat" wrote:
>
> > Hi all,
> >
> > My CSV file Contains Data like.
> > -----------------------------------
> >
> > Ex: DriverID | CustomerID | Ship to ID | Load # | BOL Date/TimeStamp |
> > ProductN
> > 520 | 2355 - | 1 | 61953 | ############ | 1 Eth 87
> >
> > My XLS file Contains Data Like.
> > ------------------------------------------------------------------------------------
> > Ex: Field Definition Length Starting Column Ending Column
> >
> > TransType Some Definition 1 1 1
> > Termin ID Some Difinition 3 3 5
> > Term SPLC Some Difi 7 6 12
> >
> > I got the Sorce code from net to Convert the .CSV file to .XLS file(but the
> > Problem is converted .XLS file is not in specified format, it should be like
> > above XLS file).
> >
> >
> > Source CodeConvert .CSV file to .XLS file )
> >
> >
> > using System;
> > using System.Collections.Generic;
> > using System.Text;
> > using System.Reflection;
> > using Microsoft.Office.Interop.Excel;
> >
> > namespace File_Conversion
> > {
> > class Program
> > {
> > static void Main(string[] args)
> > {
> > ApplicationClass app = new ApplicationClass();
> > Workbook doc = app.Workbooks._Open(
> > @"C:\GCProject\Input
> > Example.csv",
> > Missing.Value,
> > Missing.Value,
> > Missing.Value,
> > Missing.Value,
> > Missing.Value,
> > Missing.Value,
> > Missing.Value,
> > Missing.Value,
> > false,
> > Missing.Value,
> > Missing.Value,
> > false);
> > Console.WriteLine("Reading
> > CSV File........");
> > doc.SaveAs(
> > @"C:\GCProject\Output.xls",
> > XlFileFormat.xlWorkbookNormal,
> > Missing.Value,
> > Missing.Value,
> > Missing.Value,
> > Missing.Value,
> >
> > XlSaveAsAccessMode.xlExclusive,
> > Missing.Value,
> > false,
> > Missing.Value,
> > Missing.Value,
> > Missing.Value);
> > doc.Saved = true;
> > Console.WriteLine("Converted
> > CSV to XLS file");
> > app.Quit();
> > Console.ReadLine();
> >
> >
> > }
> > }
> > }
> >
> > Any body have IDEA ?
> >
> > Thanks in advance,
> >
> > Regards,
> > Liyakhat.
> >
> >

 
Reply With Quote
 
=?Utf-8?B?TGl5YWtoYXQ=?=
Guest
Posts: n/a
 
      16th Jul 2007
Hi Nick,

Thanks for the reply.

I try to Explain you:

My CSV file Contains Data like.
> -----------------------------------
>
> Ex: DriverID | CustomerID | Ship to ID | Load # | BOL Date/TimeStamp |
> ProductName
> 520 | 2355 - | 1 | 61953 | ############ | 1 Eth 87



My XLS file Contains Data Like.
> --------------------------------------------------------------------------

----------
> Ex: Field Definition Length Starting Column Ending Column
>
> DriverID Some Definition 1 1 1
> CustomerID Some Difinition 3 3 5
> Ship to ID Some Difi 7 6 12
> Load # Some difi - - -
>BOL Date/TimeStamp Some Difi - - -
> ProductName Some difi - - -



Hope I explained well.

If you need any clarification please let me know..

Thanks,
Liyakhat.

"NickHK" wrote:

> Considering there does not seem to be any correlation between the csv data
> and the desired Excel format, it's not possible to advise.
> Maybe a query in an Excel WB, so you can use SQL to control the order of the
> columns.
>
> NickHK
>
> "Liyakhat" <(E-Mail Removed)> wrote in message
> news:4CB88FE3-424E-4ABA-9FF9-(E-Mail Removed)...
> > Hi all,
> >
> > My CSV file Contains Data like.
> > -----------------------------------
> >
> > Ex: DriverID | CustomerID | Ship to ID | Load # | BOL Date/TimeStamp |
> > ProductN
> > 520 | 2355 - | 1 | 61953 | ############ | 1 Eth 87
> >
> > My XLS file Contains Data Like.
> > --------------------------------------------------------------------------

> ----------
> > Ex: Field Definition Length Starting Column Ending Column
> >
> > TransType Some Definition 1 1 1
> > Termin ID Some Difinition 3 3 5
> > Term SPLC Some Difi 7 6 12
> >
> > I got the Sorce code from net to Convert the .CSV file to .XLS file(but

> the
> > Problem is converted .XLS file is not in specified format, it should be

> like
> > above XLS file).
> >
> >
> > Source CodeConvert .CSV file to .XLS file )
> >
> >
> > using System;
> > using System.Collections.Generic;
> > using System.Text;
> > using System.Reflection;
> > using Microsoft.Office.Interop.Excel;
> >
> > namespace File_Conversion
> > {
> > class Program
> > {
> > static void Main(string[] args)
> > {
> > ApplicationClass app = new ApplicationClass();
> > Workbook doc = app.Workbooks._Open(
> > @"C:\GCProject\Input
> > Example.csv",
> > Missing.Value,
> > Missing.Value,
> > Missing.Value,
> > Missing.Value,
> > Missing.Value,
> > Missing.Value,
> > Missing.Value,
> > Missing.Value,
> > false,
> > Missing.Value,
> > Missing.Value,
> > false);
> > Console.WriteLine("Reading
> > CSV File........");
> > doc.SaveAs(
> > @"C:\GCProject\Output.xls",
> > XlFileFormat.xlWorkbookNormal,
> > Missing.Value,
> > Missing.Value,
> > Missing.Value,
> > Missing.Value,
> >
> > XlSaveAsAccessMode.xlExclusive,
> > Missing.Value,
> > false,
> > Missing.Value,
> > Missing.Value,
> > Missing.Value);
> > doc.Saved = true;
> > Console.WriteLine("Converted
> > CSV to XLS file");
> > app.Quit();
> > Console.ReadLine();
> >
> >
> > }
> > }
> > }
> >
> > Any body have IDEA ?
> >
> > Thanks in advance,
> >
> > Regards,
> > Liyakhat.
> >
> >

>
>
>

 
Reply With Quote
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      16th Jul 2007
Your objective was to import a text file into excel. The textt file is not a
CSV (comma seperatted value). Your textt file is delimited withyh the |
character. the code I supplied simply imports the text file into excel using
the | as a delimiter. the key to importing your datta is tthe followingg two
lines in the macro.

.TextFileParseType = xlDelimited
.TextFileOtherDelimiter = "|"


"Liyakhat" wrote:

> Hi Joel,
>
> But how it is usfull in converting .csv file to .xls file. ?
>
> Thanks,
> Liyakhat
>
> "Joel" wrote:
>
> > I imported your data into excel recording a macro. Here is the code I got.
> > I used delimited and set a special delimiter character | to match your data.
> >
> >
> > Sub Macro1()
> > '
> > ' Macro1 Macro
> > ' Macro recorded 7/16/2007
> > '
> > '
> > With ActiveSheet.QueryTables.Add(Connection:="TEXT;C:\TEMP\test.txt", _
> > Destination:=Range("A1"))
> > .Name = "test"
> > .FieldNames = True
> > .RowNumbers = False
> > .FillAdjacentFormulas = False
> > .PreserveFormatting = True
> > .RefreshOnFileOpen = False
> > .RefreshStyle = xlInsertDeleteCells
> > .SavePassword = False
> > .SaveData = True
> > .AdjustColumnWidth = True
> > .RefreshPeriod = 0
> > .TextFilePromptOnRefresh = False
> > .TextFilePlatform = 437
> > .TextFileStartRow = 1
> > .TextFileParseType = xlDelimited
> > .TextFileTextQualifier = xlTextQualifierDoubleQuote
> > .TextFileConsecutiveDelimiter = False
> > .TextFileTabDelimiter = False
> > .TextFileSemicolonDelimiter = False
> > .TextFileCommaDelimiter = False
> > .TextFileSpaceDelimiter = False
> > .TextFileOtherDelimiter = "|"
> > .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1)
> > .TextFileTrailingMinusNumbers = True
> > .Refresh BackgroundQuery:=False
> > End With
> > Columns("E:E").ColumnWidth = 26.57
> > Range("E3").Select
> > End Sub
> >
> > "Liyakhat" wrote:
> >
> > > Hi all,
> > >
> > > My CSV file Contains Data like.
> > > -----------------------------------
> > >
> > > Ex: DriverID | CustomerID | Ship to ID | Load # | BOL Date/TimeStamp |
> > > ProductN
> > > 520 | 2355 - | 1 | 61953 | ############ | 1 Eth 87
> > >
> > > My XLS file Contains Data Like.
> > > ------------------------------------------------------------------------------------
> > > Ex: Field Definition Length Starting Column Ending Column
> > >
> > > TransType Some Definition 1 1 1
> > > Termin ID Some Difinition 3 3 5
> > > Term SPLC Some Difi 7 6 12
> > >
> > > I got the Sorce code from net to Convert the .CSV file to .XLS file(but the
> > > Problem is converted .XLS file is not in specified format, it should be like
> > > above XLS file).
> > >
> > >
> > > Source CodeConvert .CSV file to .XLS file )
> > >
> > >
> > > using System;
> > > using System.Collections.Generic;
> > > using System.Text;
> > > using System.Reflection;
> > > using Microsoft.Office.Interop.Excel;
> > >
> > > namespace File_Conversion
> > > {
> > > class Program
> > > {
> > > static void Main(string[] args)
> > > {
> > > ApplicationClass app = new ApplicationClass();
> > > Workbook doc = app.Workbooks._Open(
> > > @"C:\GCProject\Input
> > > Example.csv",
> > > Missing.Value,
> > > Missing.Value,
> > > Missing.Value,
> > > Missing.Value,
> > > Missing.Value,
> > > Missing.Value,
> > > Missing.Value,
> > > Missing.Value,
> > > false,
> > > Missing.Value,
> > > Missing.Value,
> > > false);
> > > Console.WriteLine("Reading
> > > CSV File........");
> > > doc.SaveAs(
> > > @"C:\GCProject\Output.xls",
> > > XlFileFormat.xlWorkbookNormal,
> > > Missing.Value,
> > > Missing.Value,
> > > Missing.Value,
> > > Missing.Value,
> > >
> > > XlSaveAsAccessMode.xlExclusive,
> > > Missing.Value,
> > > false,
> > > Missing.Value,
> > > Missing.Value,
> > > Missing.Value);
> > > doc.Saved = true;
> > > Console.WriteLine("Converted
> > > CSV to XLS file");
> > > app.Quit();
> > > Console.ReadLine();
> > >
> > >
> > > }
> > > }
> > > }
> > >
> > > Any body have IDEA ?
> > >
> > > Thanks in advance,
> > >
> > > Regards,
> > > Liyakhat.
> > >
> > >

 
Reply With Quote
 
=?Utf-8?B?TGl5YWtoYXQ=?=
Guest
Posts: n/a
 
      16th Jul 2007
It is Comma seperated value(,) only.

I have given the | to understand easily when reader were reading my
question submmission.

I tell my requirement in short:

1. CSV Input File is created by user
2. My Application reads data in from CSV file
3. My Application converts records from the CSV file to a new format(.XLS)

Hope I explained well.

If you need additional information please let me know...

Thanks,
Liyakhat.

"Joel" wrote:

> This is not CSV (commar seperate values) data. The data is delimited using
> the | character.
>
> "NickHK" wrote:
>
> > Considering there does not seem to be any correlation between the csv data
> > and the desired Excel format, it's not possible to advise.
> > Maybe a query in an Excel WB, so you can use SQL to control the order of the
> > columns.
> >
> > NickHK
> >
> > "Liyakhat" <(E-Mail Removed)> wrote in message
> > news:4CB88FE3-424E-4ABA-9FF9-(E-Mail Removed)...
> > > Hi all,
> > >
> > > My CSV file Contains Data like.
> > > -----------------------------------
> > >
> > > Ex: DriverID | CustomerID | Ship to ID | Load # | BOL Date/TimeStamp |
> > > ProductN
> > > 520 | 2355 - | 1 | 61953 | ############ | 1 Eth 87
> > >
> > > My XLS file Contains Data Like.
> > > --------------------------------------------------------------------------

> > ----------
> > > Ex: Field Definition Length Starting Column Ending Column
> > >
> > > TransType Some Definition 1 1 1
> > > Termin ID Some Difinition 3 3 5
> > > Term SPLC Some Difi 7 6 12
> > >
> > > I got the Sorce code from net to Convert the .CSV file to .XLS file(but

> > the
> > > Problem is converted .XLS file is not in specified format, it should be

> > like
> > > above XLS file).
> > >
> > >
> > > Source CodeConvert .CSV file to .XLS file )
> > >
> > >
> > > using System;
> > > using System.Collections.Generic;
> > > using System.Text;
> > > using System.Reflection;
> > > using Microsoft.Office.Interop.Excel;
> > >
> > > namespace File_Conversion
> > > {
> > > class Program
> > > {
> > > static void Main(string[] args)
> > > {
> > > ApplicationClass app = new ApplicationClass();
> > > Workbook doc = app.Workbooks._Open(
> > > @"C:\GCProject\Input
> > > Example.csv",
> > > Missing.Value,
> > > Missing.Value,
> > > Missing.Value,
> > > Missing.Value,
> > > Missing.Value,
> > > Missing.Value,
> > > Missing.Value,
> > > Missing.Value,
> > > false,
> > > Missing.Value,
> > > Missing.Value,
> > > false);
> > > Console.WriteLine("Reading
> > > CSV File........");
> > > doc.SaveAs(
> > > @"C:\GCProject\Output.xls",
> > > XlFileFormat.xlWorkbookNormal,
> > > Missing.Value,
> > > Missing.Value,
> > > Missing.Value,
> > > Missing.Value,
> > >
> > > XlSaveAsAccessMode.xlExclusive,
> > > Missing.Value,
> > > false,
> > > Missing.Value,
> > > Missing.Value,
> > > Missing.Value);
> > > doc.Saved = true;
> > > Console.WriteLine("Converted
> > > CSV to XLS file");
> > > app.Quit();
> > > Console.ReadLine();
> > >
> > >
> > > }
> > > }
> > > }
> > >
> > > Any body have IDEA ?
> > >
> > > Thanks in advance,
> > >
> > > Regards,
> > > Liyakhat.
> > >
> > >

> >
> >
> >

 
Reply With Quote
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      16th Jul 2007
Where are the commas? I don't see any

DriverID | CustomerID | Ship to ID | Load # | BOL Date/TimeStamp |
ProductN
520 | 2355 - | 1 | 61953 | ############ | 1 Eth 87



 
Reply With Quote
 
=?Utf-8?B?TGl5YWtoYXQ=?=
Guest
Posts: n/a
 
      16th Jul 2007
joel,

DriverID........
520........

These values were resided in .csv file.

I will send these files to you, so u can get it what I mean to say.
May I know u r mailid plz,

Thanks,
Liyakhat.


"Joel" wrote:

> Where are the commas? I don't see any
>
> DriverID | CustomerID | Ship to ID | Load # | BOL Date/TimeStamp |
> ProductN
> 520 | 2355 - | 1 | 61953 | ############ | 1 Eth 87
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert time format to decimal format for excel? Tim Microsoft Access 1 7th Dec 2007 07:11 PM
Convert European Date format to American Format =?Utf-8?B?QWxiZXJ0?= Microsoft Excel Misc 3 21st Aug 2007 10:02 PM
Convert a latebinded DataTable column's format from DateTime to string (or format the date time value) RSH Microsoft VB .NET 0 6th Dec 2006 03:49 PM
How do I convert from Real Player format to Windows Media Format Zaheer Windows XP Music 3 5th Oct 2006 11:02 PM
Convert date format to text keeping xx/xx/xxxx format? Keith Microsoft Excel Misc 1 10th Sep 2003 03:43 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:42 AM.