iPhone detects CSV as XLS - iphone

My app is able to import CSV files from within email attachments on the iPhone. Excel is used to generate the CSV files.
Initially I set the Document Type to public.comma-separated-values-text.
This works fine with Mac based CSV files. But when Windows based CSV files are emailed, the iPhone treats them differently. The quick view fails to work on them, and it labels them as .XLS files.
Sure enough, when I call [csvFilenameString pathExtension], it should return "CSV", but instead returns "XLS". But the actual filename extension IS ".csv"!
So to support this weirdness and still be able to read them in, I had to change my apps Document Type setting to public.data.
Of course now to iOS, my app looks like it's registered in supporting every file type for email attachments.
The only difference I could tell between the two CSV type files (Mac vs. Windows) is the EOL. Mac uses LF, while Windows uses CRLF.
Still, I'm thinking iOS should be smarter to detect it properly as a CSV and not as an XLS.
Anyone else experience this?

Related

Creating readable XML for iOS

My client uses a process that uses XMLSS to create XML documents that can be opened in Microsoft Excel. In fact, simply renaming the files to .XLS, will ensure that the documents open in Excel by default. These documents are emailed to our clients. The documents open successfully in for Excel for PC and MAC, as well as OpenOffice (both platforms). It's a pretty nice solution.
The problem is, some of our clients have started attempting to open these documents (for viewing) on their iPhones and iPads (iOS devices), and it doesn't work. We know that iOS devices can open actual Office files, but since our documents are really just XML (and not true Excel files), the viewer on iOS doesn't want to view them. At least that's my guess.
We have played with sending these files with both XML and XLS extensions.
I'm aware of the option of using different techniques for building these documents such that they become true XLS files... but obviously, we're not eager to rewrite the entire application when most of our functionality remains just fine.
Any tips, ideas, suggestions?

iOS easy way to convert and store large table

I have Excel file with table ~100x100 and need to get access to this values from iOS app.
At first, I've try to make json in Mr.DataConverter and then it's not a problem to read to array. But! Some float values didn't recognized properly, and I'd got numbers without quotes:
At the time other parsed correctly!
So, from this moment I can't parse my Json string to NSArray.
The question is:
How to convert xls to json, OR How to put and retrieve the values in iOS device?
Thanks.
You can use the DHlibxls iOS Framework and simply pull the .xls file into your app, then read and process with that framework. The framework is based on the open source libxls library on SourceForge, and has a non-attributed BSD license.
I recommend exporting the Excel spreadsheet to CSV and then using a proper CSV parser to parse the data. If you run into any issues then there is likely an issue in the spreadsheet that you would need to fix.
Alternative: If possible use excel file in formate: tab delimited-text-file. That solve all your problem. Easy to open text file in iOS with file manager/c++.
convert-an-excel-spreadsheet-to-a-tab-delimited-text-file

iPhone app that reads .csv file

Can an iOS app read a file that has been placed on that device e.g. a CSV file.
So the idea is when you're at home you create the file with a list of items or you get emailed it etc on your PC and then you place this file (in the correct format) on the device which reads it.
Is this possible?
You can read CSV data but "place the file on the device" would have to involve a web service of some sort. There is no way to add data to an application without getting in a from a web server. But if you have a web server that can host the csv file then opening and reading it is fairly simple.
this covers most o it
Import csv data (SDK iphone)
NSString stringWithContentsOfURL:encoding:error
will take care of the rest
There is a string feature that will take each value and place it into an array:
NSArray *anArray = [yourString componentsSeparatedByString:#","];
You can parse CSV on an iOS device.
You can place a data file on an iOS device.
Beware though of CSV format details. Just splitting a string on "," is a surefire way to get failures and random errors. Have a look at http://cocoawithlove.com/2009/11/writing-parser-using-nsscanner-csv.html for a good example on how to handle CSV data.
I've personally used the example from cocoa with love to create an operation that downloads a CSV from a http location, parses and processes it and then stores the results in a Core-Data store.
But you could just as well get the CSV file on your device by using an NSURLConnection. Beware though: NSURLDownload is unavailable on iOS. Also downloading data to the device is not recommended. Apple recommends processing the data and storing the results or just getting the data as you need it.

Problem associating file types for iPad running IOS4.2

I'm trying to associate zip files with my program I'm writing for the iPad, but am running into problems. My custom file format that I created is recognized just fine in email attachments and dropbox. However, zip files are only recognized from dropbox and not from email attachments, (EG. dropbox->open in->my program). In email attachments it won't let me download the file and select 'open in'. This is really strange since it works fine in dropbox. The weirdest thing is that if I install Goodreader, the files work just fine as email attachments. I'm developing this program for enterprise distribution, so I'd rather not make all the employees have to buy Goodreader in order to open zip files from email attachments. I've included two .plist configurations that I've tried. Both only work if goodreader is installed.
and:
If anyone has any suggestions, I'm really stumped on this one.
OK, I figured out what was going on. In my info.plist file, I wasn't changing the bundle identifier to reflect my company name. Effectively it was registering my file types as com.novatek.iPadViewer, but it should have been com.yourcompany.iPadViewer. I changed the identifier to be com.novatek.iPadViewer and now it works great.

Upload text file on FTP server using iPhone

I have implemented code for uploading images and directory to FTP using iPhone.
But I need to upload text file on FTP using iPhone. Can you please send me code for that.
Here's an example:
http://modmyi.com/forums/iphone-ipod-touch-sdk-development-discussion/328541-ftp-usage-iphone-applications.html
It uploads one byte at a time, so be sure your strings are ASCII encoded if you are expecting ASCII.
Here is a script to upload entire directory including text, binary etc. files. It creates subdirectories as needed.
http://www.biterscripting.com/SS_FTPUpload.html
Start with that script and change it to suit your particular situation.