更新时间:2023-02-08 18:06:02
我不太确定asp.net与控制台应用程序有什么关系...如果你想将你的输出写入一个可以被excel读取的文件,然后,类似这样的东西
I'm not quite sure what asp.net has to do with a console application ... if you wish to write your output to a file that can be read by excel, then, something like this
using (System.IO.StreamWriter fileOutput =
new System.IO.StreamWriter(@"C:\Some Path\sudhakarthikeyan.csv"))
{
while (reader.Read()
{
fileOutput.WriteLine("{0},{1},{2},{3},{4}",
reader.GetInt32(0),
reader.GetString(1),
reader.GetString(2),
reader.GetString(3),
reader.GetString(4);
}
}
现在,如果您从ASP.Net而不是'控制台应用程序运行',你需要更换
C:\ Some Path
带'映射path',即您网站上的有效路径。 http://www.dotnetperls.com/mappath [ ^ ]可能是如何开始的参考
还有其他工具可以可能很有用 - FileHelpers Library [ ^ ]例如
Now, if you're running from ASP.Net instead of 'a console application', you'll need to replace
C:\Some Path
With a 'mapped path', ie a valid path on your web site. This http://www.dotnetperls.com/mappath[^] may be a reference for how to start
There are also other tools that might be useful - FileHelpers Library[^] for instance