timer - columns combining when c# appends to csv -


we've created desktop timer our users using track daily tasks , projects. outputs data .csv file when close application. going need manually update csv file either take time off or add time. when have been doing in current state after save columns combined column a. unclear on causing , tried research encoding couldn't find relate scenario.

full form1.cs: full form1.cs code

code related csv:

    //event handler closing event -- output dump here timer can used day , captures on accidetnal close     private void form1_formclosing(object sender, formclosingeventargs e)     {          //if file exists don't need write headers can skip additional line write , append data created         if (file.exists(dskpath + "\\" + agentname + ".csv"))         {             using (var file = new streamwriter(dskpath+"\\"  + agentname + ".csv", true, encoding.utf8))             {                  foreach (var data in timerdata)                 {                     file.writeline(string.join(",", data.agentid, data.agentstatus, data.statustime, data.starttime, data.currentdate, data.hydratask, data.clientname, data.publishdate, data.notes));                 }                 file.close();                 notifyicon1.icon = null;                 messagebox.show("the file " + agentname + " has been written g:\\communicator ops\\population health\\pop process\\time tracking\\user data.", "application closed");             }         }         //if file hasn't been created before can drop headers in columns         else         {             using (var file = new streamwriter(dskpath +"\\"+ agentname + ".csv", true, encoding.utf8))             {                 file.writeline(string.join(",", "agent id", "agent status", "status time", "start time", "current date", "hydra task number", "client name", "publish date", "notes"));                 foreach (var data in timerdata)                 {                     file.writeline(string.join(",", data.agentid, data.agentstatus, data.statustime, data.starttime, data.currentdate, data.hydratask, data.clientname, data.publishdate, data.notes));                 }                 file.close();                 notifyicon1.icon = null;                 messagebox.show("the file " + agentname + " has been written desktop.","application closed");             }         }     } 

i have theory might occurring. c# code looks ok. think users opening file in way not expecting. think doing following:

1) opening excel , navigating file location. cause dialog open: enter image description here

2) hit next , step 2. enter image description here

at step may leaving tab selected delimiter not correct. may causing problem.

they hit next again

3) enter image description here

finally hit finish , ends in column a. enter image description here

if double click on desktop icon seems work ok. if select comma delimiter, , uncheck tab, worked too.

that guess. out.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -