- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
class CSVSave
{
char separator = ';';
public void SaveCSV(string pathfile, IEnumerable<Product> list )
{
using (var sw = new StreamWriter(pathfile, false, Encoding.GetEncoding(1251)))
{
foreach (var prod in list)
{
string line =
prod.Manufacturer + separator +
prod.Name + separator +
prod.Type + separator +
prod.Url + separator +
prod.Imgurl + separator +
prod.Sex + separator +
prod.Volume + separator +
prod.Box + separator +
prod.Price + separator +
prod.availability + separator +
prod.Desk;
if ((prod.Family != null) || (prod.QuantityPurchased != null) || (prod.Application != null) || (prod.Flavornotes != null) || (prod.Production != null)) line += separator;
if (prod.QuantityPurchased != null) line += prod.QuantityPurchased + separator;
if (prod.Family != null) line += prod.QuantityPurchased + separator;
if (prod.Production != null) line += prod.QuantityPurchased + separator;
if (prod.Application != null) line += prod.QuantityPurchased + separator;
if (prod.Flavornotes != null) line += prod.QuantityPurchased + separator;
line=line.Trim(separator);
sw.WriteLine(line);
}
sw.Close();
}
}
}
cyperh 18.12.2014 00:39 # 0
Lennis 18.12.2014 03:36 # +1
pushistayapodmyshka 18.12.2014 07:23 # +3
>"CSV" is not a single, well-defined format (although see RFC 4180 for one definition that is commonly used). Rather, in practice the term "CSV" refers to any file that:
>with the records divided into fields separated by delimiters (typically a single reserved character such as comma, semicolon, or tab; sometimes the delimiter may include optional spaces)
Короче, все забили на название.
guest 18.12.2014 07:34 # +1
pushistayapodmyshka 18.12.2014 07:39 # 0
inkanus-gray 18.12.2014 07:45 # 0
pushistayapodmyshka 18.12.2014 07:47 # 0
heyzea1 18.12.2014 10:34 # +3
guest 20.12.2014 05:49 # −2
guest 18.12.2014 10:50 # −2
Мудачье не знает про join?
guest 18.12.2014 20:04 # −5
guest 20.12.2014 12:21 # 0
koodeer 18.12.2014 14:58 # +1
hack2root 09.01.2015 23:52 # 0