You are viewing limited content. For full access, please sign in.

Question

Question

Export CSV SDK formatting

asked on January 7, 2019

So I am using workflow to output a csv file for use in another system.

Workflow seems to be taking the code from the Form and putting them in the csv but it is being treated as a date field.  

Creating the csv file

dim txtfile as String = "E:\LFTransfer\TestExport\" & GetTokenValue("RetrieveBusinessProcessVariables_vendorname") & " - " & GetTokenValue("RetrieveBusinessProcessVariables_invnum") & ".csv"

Workflow track tokens showing the value:

Writing the line to the csv

 w.WriteLine("APDF" & ",,,,,,,,,,," & GetTokenValue("ForEachCode_GL_Code"))

Opening the csv:

 

Result file when opened in notepad to verify formatting:

 

Since a csv should ignore formatting, any idea as to what needs to happen in the code to get it to put the number with the dashes I need?

 

Thanks,

Chris

0 0

Replies

replied on January 7, 2019

Excel does change things to how it thinks the user would want to see it.

If you are going to only open these in Excel, I would suggest adding a =" before and " after the date, w.WriteLine("APDF" & ",,,,,,,,,,,=""" & GetTokenValue("ForEachCode_GL_Code") & """"). This will have Excel treat it as a string formula rather than a date as the default.

If you are using a different program, check with that program to see how it handles this field. Several programs that use CSV format does not automatically change the values to dates like Excel.

Also when testing use a new file rather than one that went through Excel. Excel like to change things if it thinks it knows better.

1 0
replied on January 7, 2019

The only way that the dashes would get replaced is if you opened it in Excel and then saved the file. If you import the data using the Text Import Wizard, you can specify how to treat each column.

1 0
replied on January 8, 2019

As people have already said, Excel likes to think it knows better. Excel samples the data in the column and decides the data type based on the first few rows, then uses that for display. It shouldn't affect other applications reading from the CSV, but Michael's suggestion of adding quotes is a good one. Without double quotes, if your form data contains a comma, it will throw off your CSV formatting.

0 0
replied on January 8, 2019

Thanks all, it seems the user was saving the file after opening it which is why the formatting showed.  If I opened the file directly after the workflow in notepad it showed like it should.

Good to know about the double quote.  I tried the quote but inside the get token value instead of outside where it looks like it should be.

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.