I have this line, how do I append text with the varaibles to make up the headings?
StringBuilder sb = new StringBuilder();
week6 = model.SelectedSunday.AddDays(-7);
week5 = week6.AddDays(-7);
week4 = week5.AddDays(-7);
week3 = week4.AddDays(-7);
week2 = week3.AddDays(-7);
week1 = week2.AddDays(-7);
sb.AppendLine("Title, Total, " week6, week5, week4, week3, week2, week1 );
and also this code:
var tradesmenReportData = _reportingService.GetTradeUKKPITradesmen(model.SelectedSunday);
var jobSortedReportData = _reportingService.GetTradeUKKPIJobSorted(model.SelectedSunday);
foreach (var item in tradesmenReportData)
{
sb.AppendLine(String.Concat("\"", item.Title, "\", item.Total, "\", item.Week6, "\", ", item.Week5, "\", ", item.Week4, "\", ", item.Week3, "\", ", item.Week2, "\", ", item.Week1));
}
In the output file(excel), the values has a ” appended to the values? Somewhere in above line there is an extra “.Where have I gone wrong?
thanks
the AppendFormat overload will replace the place holders with the parameters you pass to the method (week6/week5 etc).
For the second snippet, you can use this again: