开发者

CSV file download to ipad

开发者 https://www.devze.com 2023-03-14 22:14 出处:网络
I am developing a data capture web app, primarily targetting iPad usage.Multiple users will primarily capture data on iPads, but then a manager will typically download all captured records onto a PC.

I am developing a data capture web app, primarily targetting iPad usage. Multiple users will primarily capture data on iPads, but then a manager will typically download all captured records onto a PC.

Even though the file download will primarily target PCs, I am pondering whether I s开发者_如何学JAVAhould try and support file downloads to the iPad itself.

The server app is an MVC2 ASP.NET app, and I'm using a controller that returns a File result. Test code is as follows:

public ActionResult DownloadResponseData(string profileid)
        {
            string billcsv = "account_ref,line1,line2,line3";
            var data = System.Text.Encoding.UTF8.GetBytes(billcsv);
            string filename = "billfor.csv";
            return File(data, "text/csv", filename);
        }

Even though the majority of people will download to their PCs, because I am supporting full-screen iPad usage I am using the following client-side code to initiate the file download:

var url="/Download/DownloadResponseData?profileid=" + downloadRequest.profileid + "&unique=" + escape(Date());
window.open(url);

This works fine for non-iPad usage - it downloads the file nicely in Chrome.

My questions are numerous: does it make sense to download a CSV file to an iPad? Does an iPad support CSV? Do I need other software on the iPad to view a CSV file? How should I change the above code to download 'cleanly' to an iPad?

When I run the code above on the iPad, then it simply displays the entire CSV file contents within the iPad window - it doesn't seem to recognise the http response as a file.

Sorry for the rather obtuse question. Thanks.


Yes it makes sense to download csv files to the iPad, a number of iPad apps can deal with them successfully.

However, I find that mobile safari is hit or miss - it will download my activity in csv from the Amex web site okay (displays in spreadsheet form and offers to open in Numbers, DropBox, and other apps), but when I click download to get a csv file of activity on the Chase site, nothing at all happens. I even tried a third part web browser, same thing (although they all use the same webkit underneath I guess).

0

精彩评论

暂无评论...
验证码 换一张
取 消