zoukankan
html css js c++ java
XML转换为CSV
Code
1
protected
void
Page_Load(
object
sender, EventArgs e)
2
{
3
string
FileId
=
Request[
"
FileId
"
].ToString();
4
5
string
valstr
=
""
;
6
7
System.IO.StreamReader sr
=
new
System.IO.StreamReader(Server.MapPath(
"
~/xml/
"
+
FileId
+
"
.xml
"
));
8
9
//
将流转成结果集
10
DataSet ds
=
new
DataSet();
11
ds.ReadXml(sr);
12
13
14
for
(
int
i
=
0
; i
<
ds.Tables[
0
].Columns.Count; i
++
)
15
{
16
valstr
+=
"
\
""
+ ds.Tables[0].Columns[i].ColumnName +
"
\
"
,
"
;
17
}
18
valstr
+=
"
\n
"
;
19
20
for
(
int
i
=
0
; i
<
ds.Tables[
0
].Rows.Count; i
++
)
21
{
22
for
(
int
j
=
0
; j
<
ds.Tables[
0
].Columns.Count; j
++
)
23
{
24
valstr
+=
"
\
""
+ds.Tables[0].Rows[i][j].ToString() +
"
\
"
,
"
;
25
}
26
valstr
+=
"
\n
"
;
27
}
28
29
Response.ClearHeaders();
30
Response.AppendHeader(
"
Content-disposition
"
,
"
attachment;filename=test.csv
"
);
31
Response.BinaryWrite(System.Text.Encoding.GetEncoding(
"
gb2312
"
).GetBytes(valstr));
32
Response.End();
33
}
查看全文
相关阅读:
Android Api 检查參数状态Api
【Jquery】prop与attr的差别
【CODEFORCES】 A. Dreamoon and Sums
使用<jsp:include>,不想写死URL,动态生成URL的解决的方法
android.app.Activity 的介绍
字符变换
android之获取屏幕的宽度和高度
2015跑过的路
hdu5418--Victor and World(floyd+状压dp)
解决PL/SQL Developer 连接oracle 11g 64位中的问题
原文地址:https://www.cnblogs.com/jgjgjg23/p/1449587.html
最新文章
Python selenium -- cookie处理
python selenium --鼠标事件
python selenum ---如何定位一组元素
python selenium --一些常用方法
python selenium --处理下拉框
python selenium--常用函数3
python selenium--常用函数1
selenium2.0 --常用函数2
python --闭包学习
FreeBSD Top States
热门文章
Ubuntu的默认root密码
Windows 8.1硬盘安装Ubuntu 14.04双系统
在 RedHat/CentOS 7.x 中使用 nmcli 命令管理网络
JAVA 一个或多个空格分割字符串
Linux系统下用find命令查找最近修改过的文件
AIX查看某个端口被哪个进程占用
CentOS进入图形界面
Ruby print
Ruby中写换行
window8.1 CenterOS 双系统
Copyright © 2011-2022 走看看