首页 新闻 会员 周边

FileStream如何写入文本

0
悬赏园豆:10 [已关闭问题] 关闭于 2012-06-13 12:13

FileStream file = RenderDataTableToExcel(table) as FileStream;

 

 

RenderDataTableToExcel()是个方法,我现在要把读到的流数据写入到一个

 

excel文件里,该怎么写呢!!???急用!

需要格局的主页 需要格局 | 老鸟四级 | 园豆:2145
提问于:2012-06-12 15:40
< >
分享
所有回答(3)
0
dudu | 园豆:31003 (高人七级) | 2012-06-12 16:08
0

类似与操作数据库表:

连接excel文件

执行数据的添加

关闭excel连接

具体实现:

    string connectionStr = string.Format(" Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = {0};" +
            " Extended Properties= Excel 8.0", filePath);
            oledbConnection = new OleDbConnection(connectionStr);

 string sqlStr = "insert into[Sheet1$] (f1,f2)";
 oledbConnection.Open();
 OleDbCommand command = new OleDbCommand(sqlStr, oledbConnection);
 command.ExecuteNonQuery();

CloseConnection();

 

闪电风 | 园豆:125 (初学一级) | 2012-06-12 16:40
0

StreamWrite sw = new StreamWrite(path); //path:Excel路径

sw.write(file);

郑习坤 | 园豆:1 (初学一级) | 2012-06-12 16:44
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册