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:
at step may leaving tab selected delimiter not correct. may causing problem.
they hit next again
finally hit finish , ends in column a.
if double click on desktop icon seems work ok. if select comma delimiter, , uncheck tab, worked too.
that guess. out.
Comments
Post a Comment