Write custom delimiter text into MS excel

#1
Hi All,

Below method shows writing text into excel ,this is another way to write excel in more efficient way from text file.

Input Value : Collection(input collection), Delimiter(#,|,$....), Target(example C:\Temp\Test.txt)

C# Code : Create CSV file with Custom delimiter
=========
StringBuilder sb =new StringBuilder();

string[]columnNames = Collection.Columns.Cast<DataColumn>().
Select(column =>column.ColumnName).
ToArray();
sb.AppendLine(string.Join(Delimiter,columnNames));

foreach(DataRow row in Collection.Rows)
{
string[]fields = row.ItemArray.Select(field=>field.ToString()).
ToArray();
sb.AppendLine(string.Join(Delimiter,fields));
}
File.WriteAllText(Target,sb.ToString());
===================
External Reference :
-------------------------
System.Windows.Forms.dll
System.Core.dll
System.Data.DataSetExtensions.dll

Namespace :
-------------
System.Collections.Generic
System.Text
System.Collections
System.Windows.Forms
System.IO
System.Linq
----------------------------
In Blue prism :
------------------
1. Create text file from Utility- File Management
2. Call above C# action
3. Modified Import 'Import CVS' action for custom delimiter in 'MS Excel' VBO

Thanks,
Sheel
 
Top