写入CSV文件 [英] Writing to a CSV file

查看:96
本文介绍了写入CSV文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我有一个小应用程序,我需要将数据从7个文本框保存到

一个csv文件。这将需要btnNext_Click函数,它将创建一个新的
csv文件,并在csv文件中输入7个数据字段;同样,接下来每次点击

将返回一个新行。


客户端不是他在Access数据库中的数据(他讨厌Access一个

激情) - 他对Excel感觉更舒服。这个数据不会超过
每次使用1000行。

TIA


Aaron

Hello,

I have a small application that I need to save data from 7 text boxes in to
a csv file. This will entail btnNext_Click function that will create a new
csv file and enter the 7 data fields in the csv file; as well, each click on
next will return carriage to a new line.

Client does not what his data in an Access database(he hates Access with a
passion)--he feels more comfortable with Excel. This data will be no greater
than 1000 lines per use.
TIA

Aaron

推荐答案

你好!

你没有问过任何问题,你刚刚写了你的应用程序在做什么。

if你想回答写下你的问题

guy


" Aaron"写道:
Hello!
you didn''t ask any question, you just wrote what your application is doing.
if you want answer write your problem
guy

"Aaron" wrote:
你好,

我有一个小应用程序,我需要将数据从7个文本框保存到一个csv文件。这将需要btnNext_Click函数,它将创建一个新的
csv文件,并在csv文件中输入7个数据字段;同样,每次单击
接下来都会将回车换回新的一行。

客户端不会将他的数据存放在Access数据库中(他讨厌具有激情的Access) - - 使用Excel感觉更舒服。这个数据不会超过每次使用1000行。

TIA

Aaron
Hello,

I have a small application that I need to save data from 7 text boxes in to
a csv file. This will entail btnNext_Click function that will create a new
csv file and enter the 7 data fields in the csv file; as well, each click on
next will return carriage to a new line.

Client does not what his data in an Access database(he hates Access with a
passion)--he feels more comfortable with Excel. This data will be no greater
than 1000 lines per use.
TIA

Aaron



小伙,


对不起


我想知道以下怎么做

1)创建一个.csv文件 - 表格顶部会有一个文本框

,它将具有文件名。

2)格式每次点击btnNext时,来自7个文本框的数据行然后返回




tia


Aaron

" guy" < gu*@discussions.microsoft.com>在消息中写道

news:16 ********************************** @ microsof t.com ...
guy,

Sorry

I want to know how too do the following
1) create a .csv file--there will be a single text box on top of the form
that would have the name of the file.
2) format the line of data from the 7 text boxes then carriage return on
each time btnNext is clicked.

tia

Aaron
"guy" <gu*@discussions.microsoft.com> wrote in message
news:16**********************************@microsof t.com...
你好!
你没有问任何问题,你刚刚写了你的应用程序是
做什么。如果你想回答写下你的问题


Aaron写道:
Hello!
you didn''t ask any question, you just wrote what your application is doing. if you want answer write your problem
guy

"Aaron" wrote:
你好,

我有一个小应用程序,我需要将
中的7个文本框中的数据保存到csv文件中。这将需要btnNext_Click函数,它将创建一个
的新csv文件,并在csv文件中输入7个数据字段;同样,每个
点击下一个将返回一个新行。

客户端不是他在Access数据库中的数据(他讨厌以
a激情访问) - 他对Excel感觉更舒服。这个数据不会超过
每次使用超过1000行。

TIA

Aaron
Hello,

I have a small application that I need to save data from 7 text boxes in to a csv file. This will entail btnNext_Click function that will create a new csv file and enter the 7 data fields in the csv file; as well, each click on next will return carriage to a new line.

Client does not what his data in an Access database(he hates Access with a passion)--he feels more comfortable with Excel. This data will be no greater than 1000 lines per use.
TIA

Aaron



protected void btnNext_Click(object sender,EventArgs e)

{

StreamWriter sw = new StreamWriter(filename,true);

sw.WriteLine(string.Concat

(textBox1.Text

,textBox2.Text

,textBox3.Text

,textBox4.Text

,textBox5.Text

,textBox6.Text

,textBox7.Text)) ;

sw.Close();

}


但是也许在模块全局范围内使用StreamWriter,

如果你想避免在Next按钮上每次点击都打开文件,但是

而是初始化

一次并关闭它一次。


-

问候,

DennisJDMyrén

奥斯陆Kodebureau

"亚伦" <吴**** @ hotmail.com>在消息中写道

news:em ************* @ TK2MSFTNGP12.phx.gbl ...
protected void btnNext_Click ( object sender, EventArgs e )
{
StreamWriter sw = new StreamWriter(filename, true);
sw.WriteLine(string.Concat
( textBox1.Text
, textBox2.Text
, textBox3.Text
, textBox4.Text
, textBox5.Text
, textBox6.Text
, textBox7.Text ));
sw.Close();
}

But maybe use the StreamWriter in a module global scope,
if you want to avoid opening the file for each click on the Next button,but
rather initialize
it once and close it once.

--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Aaron" <wu****@hotmail.com> wrote in message
news:em*************@TK2MSFTNGP12.phx.gbl...
guy,

抱歉

我想知道以下怎么做
1)创建.csv文件 - 表单顶部会有一个文本框
那将有文件的名称。
2)格式化7个文本框中的数据行,然后每次点击btnNext时回车。

tia

Aaron

" guy" < gu*@discussions.microsoft.com>在消息中写道
新闻:16 ********************************** @ microsof t.com。 ..
guy,

Sorry

I want to know how too do the following
1) create a .csv file--there will be a single text box on top of the form
that would have the name of the file.
2) format the line of data from the 7 text boxes then carriage return on
each time btnNext is clicked.

tia

Aaron
"guy" <gu*@discussions.microsoft.com> wrote in message
news:16**********************************@microsof t.com...
你好!
你没有问过任何问题,你刚刚写了你的应用程序在做什么。
Hello!
you didn''t ask any question, you just wrote what your application is doing.
如果你想回答你写的问题<男孩

Aaron写道:
if you want answer write your problem
guy

"Aaron" wrote:
你好,

我有一个小应用程序,我需要将数据从7个文本框保存
Hello,

I have a small application that I need to save data from 7 text boxes


in a csv文件。这将需要btnNext_Click函数,它将创建一个新的csv文件并输入csv文件中的7个数据字段;同样,每次点击下一步都会返回一个新行。

客户端不是他在Access数据库中的数据(他讨厌Access

in to a csv file. This will entail btnNext_Click function that will create a new csv file and enter the 7 data fields in the csv file; as well, each click on next will return carriage to a new line.

Client does not what his data in an Access database(he hates Access


with

with

激情) - 他对Excel感觉更舒服。这个数据每次使用不超过1000行。

TIA

Aaron
a passion)--he feels more comfortable with Excel. This data will be no greater than 1000 lines per use.
TIA

Aaron




这篇关于写入CSV文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆