简体   繁体   English

是否可以使OData返回CSV或URL?

[英]Can OData be made to return CSV or URL?

I'm new to OData so I'm sorry if this is a bad question, but I fail to find an answer. 我是OData的新手,所以很抱歉这是一个不好的问题,但我找不到答案。

I have a bunch of OData tables, and I would like to provide an option for the user to get the data as a CSV-file. 我有一堆OData表,我想为用户提供一个以CSV文件形式获取数据的选项。

Now I know OData only supports Atom and JSON, but is there any way to make it return a filestream, or a URL? 现在我知道OData仅支持Atom和JSON,但是有什么方法可以使其返回文件流或URL?

I was thinking a URL could direct to a REST-service (not OData) that simply returns a filestream, if filestream directly from OData is impossible. 我当时想,如果无法直接从OData获得文件流,则URL可以定向到仅返回文件流的REST服务(而不是OData)。

Any thoughts or ideas are appreciated! 任何想法或想法表示赞赏!

I'm not totaly sure why you want to use oData. 我不太确定为什么要使用oData。 But oData essentially means to publish any kind of data in JSON/atom standard format - not CSV. 但是oData本质上意味着以JSON / atom标准格式发布任何类型的数据,而不是CSV。

If you have controll over your oData source you could modify an oData Producer to output CSV filestreams instead of JSON/atom files.(But you wouldn't have a real oData feed anymore) You could also set up any oData Consumer (you can find those at odata.org ) to read your oData source and display it as CSV. 如果您可以控制oData源,则可以修改oData生产者以输出CSV文件流而不是JSON / atom文件。(但是您将不再有真正的oData feed。)您还可以设置任何oData使用者(您可以找到在odata.org上的代码 )以读取您的oData源并将其显示为CSV。

If you choose a server side solution(PHP/JSP/ASP etc.) it should be rather simple to loop through the results of a request and add seperators inbetween. 如果选择服务器端解决方案(PHP / JSP / ASP等),则遍历请求结果并在两者之间添加分隔符应该非常简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM