Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Mon Dec 22, 2014 7:59 pm

I am using Spire XLS to create CSV files from my system. This files are used for inport in another system. THis other system does not support text qualifiers and expects all field without text qualifiers. The delimeter I can set to the | sign.

Spire XLS doesn't have the possibility to specify the qualifier, does any one know a easy workaround for this?

erqvu
 
Posts: 4
Joined: Tue Sep 16, 2014 12:06 pm

Tue Dec 23, 2014 3:07 am

Dear erqvu,

Thanks for your inquiry.

For your requirement, you can refer to the code below:
Code: Select all
Workbook wb = new Workbook();
wb.LoadFromFile("DatatableSample.xlsx", ExcelVersion.Version2010);
Worksheet ws = wb.Worksheets[0];
ws.SaveToFile("Sample.csv", "|", Encoding.UTF8);
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Wed Dec 24, 2014 8:45 am

Helas, this doesn't help for me. I tried you code but still get the text qualifier.

Dim Delimeter As String = "|"
Dim workbook As New Spire.Xls.Workbook()
workbook.LoadFromFile(PathFileName, Spire.Xls.ExcelVersion.Version2010)
Dim sheet As Spire.Xls.Worksheet = workbook.Worksheets(0)

' Add the data to the excel sheet,
'Then save the file

sheet.SaveToFile(OutputPathFileName, Delimeter, Encoding.UTF8)

The result is still:
"naam_organisatie"|"straat"|"huisnummer"|"toevoeging"|
Where I need:
naam_organisatie|straat|huisnummer|toevoeging|


In the mean time I hace started rewrited my code to using a Textwriter and doingit that. I was just find it a lot easy using XLS.

Hoop there is a solution.

REgards Ediwn

erqvu
 
Posts: 4
Joined: Tue Sep 16, 2014 12:06 pm

Wed Dec 24, 2014 9:25 am

Dear erqvu,

I just updated my code to meet your requirement, you can refer to that below:
Code: Select all
Workbook wb = new Workbook();
wb.LoadFromFile("DatatableSample.xlsx", ExcelVersion.Version2010);
Worksheet ws = wb.Worksheets[0];
string data = string.Empty;
using (MemoryStream ms = new MemoryStream())
{
    ws.SaveToStream(ms, "|", Encoding.UTF8);
    data = Encoding.UTF8.GetString(ms.ToArray());
}
string result = data.Replace("\"", "");
File.WriteAllText("New.csv", result, Encoding.UTF8);
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Wed Dec 24, 2014 10:15 am

Cheers thanks a lot. I have updated my code and it working fine.
Thnaks for the help

erqvu
 
Posts: 4
Joined: Tue Sep 16, 2014 12:06 pm

Thu Dec 25, 2014 1:03 am

Dear erqvu,

Glad to hear that your code work.

Please feel free to contact us if you have any problems.
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Return to Spire.XLS