如何将数据集转换为文本文件并保存在文件夹中 [英] How to convert dataset to text file and save in folder

查看:103
本文介绍了如何将数据集转换为文本文件并保存在文件夹中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的数据集包含表格形式的数据,我希望该表格应该在html文件中,所以我可以将该文本文件邮寄给客户端请帮助

I have dataset containing data in the form of a table and i want that table should be in html file so can i mail that text file to the client please help

推荐答案

StringBuilder SB = new StringBuilder();
                    StringWriter SW = new StringWriter(SB);
                    HtmlTextWriter htmlTW = new HtmlTextWriter(SW);
                    pnlDetails.RenderControl(htmlTW);
 
                    
                    string body=SB.ToString();







// Create a writer and open the file:
StreamWriter log;

if (!File.Exists("logfile.txt"))
{
  log = new StreamWriter("logfile.txt");
}
else
{
  log = File.AppendText("logfile.txt");
}

// Write to the file:
log.WriteLine(body);
log.WriteLine();

// Close the stream:
log.Close();


如果要发送带表的邮件然后你可以这样做。



1)将表格绑定到gridview

2)将gridview放在面板控件中

3)你可以将你的面板渲染成html控件和发送邮件。



If you want to send mail with table data then you can do it like this.

1) bind table to gridview
2) put gridview in panel control
3) and you can render your panel as html control ans send mail.

StringBuilder SB = new StringBuilder();
                    StringWriter SW = new StringWriter(SB);
                    HtmlTextWriter htmlTW = new HtmlTextWriter(SW);
                    pnlDetails.RenderControl(htmlTW);

                    
                    string body=SB.ToString();





将您的面板ID替换为pnlDetails

现在您可以通过邮件发送您的遗体



replace your panel id to pnlDetails
now you can send your body in mail


这篇关于如何将数据集转换为文本文件并保存在文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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