【发布时间】:2014-03-25 11:01:33
【问题描述】:
我有一个 .xls 文件,其中包含 5 列(id、name、address、phone、mobile)和各自的值。我必须以编程方式创建一个 xml 文件,并在 xml 文件中仅写入 5 个列值中的 3 个(id、name、mobile)。
我正在使用下面的代码从网络获取数据,并首先将其写入工作正常的 xls 文件。但是从 xls 获取数据并创建和写入 xml 是缺失的..
FtpWebResponse response = (FtpWebResponse)req.GetResponse();
Stream stream = response.GetResponseStream();
byte[] buffer = new byte[2048];
FileStream fs = new FileStream(DownloadedxlsFilePath, FileMode.Create);
int ReadCount = stream.Read(buffer, 0, buffer.Length);
while (ReadCount > 0)
{
fs.Write(buffer, 0, ReadCount);
ReadCount = stream.Read(buffer, 0, buffer.Length);
}
ResponseDescription = response.StatusDescription;
fs.Close();
stream.Close();
所以有两种方法: 1.获取全部数据并选择需要的数据,然后创建并写入一个xml 2. 使用上述代码轻松将数据写入.xls 文件,然后使用C# 逻辑获取所需数据,然后写入xml。
任何人都可以在 c# 中对上述任何一种方法提供帮助吗?
【问题讨论】:
标签: c# asp.net xml wpf windows-services