以编程方式从网页保存Excel文件 [英] Programatically saving a excel file from the web page

查看:57
本文介绍了以编程方式从网页保存Excel文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个显示一些报告的网页.当我单击excel链接时,它将屏幕上显示的所有数据放入CSV文件中,并打开文件下载"窗口,该窗口允许我打开,保存或取消.

I have a web page which displays some report. When I click on the link for excel, it puts all the data that is displayed on the screen into a CSV file and opens a File Download window which lets me either Open, Save or Cancel.

我想以编程方式将此文件下载到指定位置,而用户看不到文件下载"窗口.我正在使用Windows应用程序.我没有显示此报告的网站代码,因此没有数据集.另外,我查看了通过在页面上执行视图源而生成的HTML,但是我无法真正抓取它来获取数据.

I want to download this file to a specified location programatically without the user seeing the File Download window. I am using a Windows Application. I dont have the code for the website displaying this report hence dont have the dataset. Also, I looked into the HTML that gets generated by doing a view source on the page but I can't really scrape through it to get the data.

因此,我需要知道如何将Excel文件从给定的网站下载到计算机上的某个位置.

Hence I need to know how to download an excel file from a given website to a location on my computer.

预先感谢

丽塔

推荐答案

好,您需要找到适当的链接或发布操作.然后,您可以使用类似的内容:

Well you'll need to find the appropriate link or post action. You can then use something like:

string url = "http://whatever/.../foo.xsl";
string target = @"c:/excel documents/foo.xsl";
WebClient client = new WebClient();
client.DownloadFile(url, target);

如果您需要进行身份验证等,则会变得更加复杂.

It gets a bit more complicated if you need to authenticate etc though.

这篇关于以编程方式从网页保存Excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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