我正在使用数据表储存数据。
我将数据从数据表输出到CSV档案。
有时可能含有 com(,
)的数值,因此这些数值不正确出口。
For Example
数值为<代码>9,11,32”。 我必须出口。
But when I do the first column conatins 9
then in next column 11
.
我想在CSV档案的同一栏中显示9,11,32<>/code>。 我如何这样做?
我正在使用数据表储存数据。
我将数据从数据表输出到CSV档案。
有时可能含有 com(,
)的数值,因此这些数值不正确出口。
数值为<代码>9,11,32”。 我必须出口。
But when I do the first column conatins 9
then in next column 11
.
我想在CSV档案的同一栏中显示9,11,32<>/code>。 我如何这样做?
简单地把你的数据放在像“......”+你的数据+“”。
StringWriter csv = new StringWriter();
// Generate header of the CSV file
csv.WriteLine(string.Format("{0},{1}", "Header 1", "Header 2"));
// Generate content of the CSV file
foreach (var item in YourListData)
{
csv.WriteLine(string.Format("{0},{1}", item.Data1, """ + item.Data2 + """));
}
return File(new System.Text.UTF8Encoding().GetBytes(csv.ToString()), "application/csv", string.Format("{0}{1}", "YourFileName", ".csv"));
例如: 您的数据2 可能含有 com子“,”
Fields with embedded commas
must be delimited with double-quote characters.
<>光线>
abc, xyz
pqr
<<>strong>csv edition:
"abc, xyz" , pqr
含有<条码>双重引用的条码>特征的方面必须以双重引用为重,嵌入的双重引用必须分别以连续的双字母为代表。
http://www.ohchr.org。
Welcome to "My World"
<<>strong>csv edition:
"Welcome to ""My World"""
如果在数据中有一个ma子,你需要将。 引言如下:
"123,56","A dog, cat and a frog"
StringBuilder sb = new StringBuilder();
foreach (DataColumn col in dt.Columns)
{
if (col.ColumnName.Contains(","))
{
sb.Append(String.Format(""{0}",", col.ColumnName));
}
else
{
sb.Append(String.Format("{0},", col.ColumnName));
}
}
双重引用的价值。
string ValueToEscape = "a,b";
""" + ValueToEscape + """
CSV Output = a,b
书写使双面引述的价值分离,没有空间为 com子分离的数值形成一栏。
页: 1 页: 1 价值Code01 &Val1,Val2,Val3。 制作记本栏下特定数据记号的记号,并用剪辑予以保存。
Code,Description
Code01,"Val1,Val2,Val3"
What is the use of default keyword in C#? Is it introduced in C# 3.0 ?
I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...
I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...
I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...
I have two EF entities. One has a property called HouseNumber. The other has two properties, one called StartHouseNumber and one called EndHouseNumber. I want to create a many to many association ...
How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...
Since I cannot order my dictionary, what is the best way of going about taking key value pairs and also maintaing an index?
Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...