是否可以读取在线托管文件的文本值? [英] Is it possible to read text value of files hosted online ?

查看:107
本文介绍了是否可以读取在线托管文件的文本值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的Windows应用程序,用C#[winforms]编码,使用SQL Compact数据库3.5和我试图在每台PC上首次运行应用程序时获取/读取文本数据值



我试图从Excel工作表中读取数据\ Access数据库\ MySql数据库\文件文件[免费托管计划 b>]但它们都失败了(主要是因为所有免费托管网站都没有提供对文件的远程访问)。



所以有没有解决这个问题的方法?我只是想从文件中读取数据,仅此而已。

I've a pretty simple windows application coded in C# [winforms] using SQL Compact database 3.5 and I'm trying to fetch / read text data values at the first run of the application on each PC.

I've tried to read data from Excel sheet \ Access database \ MySql database \ text files [ON FREE HOSTING PLANS] but they all failed (mostly because all the free hosting websites don't offer remote access to files).

So is there any work around to this issue ? I just want to read data from files , nothing more.

推荐答案

Sherif Kamel写道:
Sherif Kamel wrote:


嗯,你引导我走的路。我已经搜索了HTTP请求,并提出了一个代码,可以正常连接到文本文件。非常感谢。

但是excel文件表怎么样?我可以用同样的方式读取它的数据吗?

Well , you guided me to the way. I've searched for the HTTP requests and came up with a code that enabled the connection to the text file normally. Thanks a lot.
But what about excel file sheet ? can I read it's data the same way?

方式不一样,但是......



我建议使用Microsoft Open XML SDK。我希望您的文件不是过时的专有.xls格式,而是基于国际ISO / IEC 29500:2008标准和公开可用的ECMA-376标准的.xlsx格式:

http://en.wikipedia.org/wiki/Office_Open_XML



请参阅本文中引用的过去的答案:如何从MS Visual中添加参考添加microsoft excel 15.0对象库Studio 2010



另请参阅此CodeProject文章:使用Open XML创建基本的Excel工作簿



对不起,它致力于创建一本工作簿,但它可以给你一般的想法。







请注意服务器端你可以做差异事情。您可以托管文件并使用HTML anchors 简单地呈现它们。但是您可以使用某些数据动态编写文件,并根据请求提供这些文件。对于ASP.NET,您可以使用上面提到的相同的非常开放的XML SDK(在这种情况下,我引用的CodeProject文章就是它)。



这里的关键是设置正确的 ContentType HttpResponse 。这些类型是IANA支持的字符串:

http:// www。 iana.org/assignments/media-types/media-types.xhtml

http://www.iana.org/assignments/media-types/media-types.xhtml#application



另请参阅: http://en.wikipedia.org/wiki/Internet_Assigned_Numbers_Authority



-SA

Not quite the same way, but…

I would advise to use Microsoft Open XML SDK. I hope your files are not of obsolete and proprietary .xls format, but in .xlsx format based on the international ISO/IEC 29500:2008 standard and publicly available ECMA-376 standard:
http://en.wikipedia.org/wiki/Office_Open_XML.

Please see my past answers referenced in this one: How to add microsoft excel 15.0 object library from Add Reference in MS Visual Studio 2010.

See also this CodeProject article: Creating basic Excel workbook with Open XML.

Sorry, it is devoted to the creation of a workbook, but it can give you the general idea.



Note that on the server side you can do different things. You can host the files and simply present them using HTML anchors. But you can compose the files on the fly out of some data and provide them on request. In case of ASP.NET, you can do it using the same very Open XML SDK mentioned above (and, in this case, the CodeProject article I referenced would be the very it).

The key here is to set correct ContentType of you HttpResponse. These types are strings supported by IANA:
http://www.iana.org/assignments/media-types/media-types.xhtml,
http://www.iana.org/assignments/media-types/media-types.xhtml#application.

See also: http://en.wikipedia.org/wiki/Internet_Assigned_Numbers_Authority.

—SA


这篇关于是否可以读取在线托管文件的文本值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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