-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fixed the strange formatting issue.
- Updated the example Note: “\t”, “\n” and “\r” will replace by empty string.
- Loading branch information
1 parent
ee4965f
commit 2484c77
Showing
2 changed files
with
14 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,62 +18,32 @@ import SwiftCSVExport | |
|
||
class ViewController: UIViewController { | ||
|
||
var task: String = "" | ||
|
||
var tasks: String = "" | ||
|
||
|
||
var DMID: String = "123456789" | ||
var RECORDID: String = "PCA12345D" | ||
var First : String = "Leah" | ||
var Last : String = "Schmidt" | ||
var Company: String = "Lab Cab Inc" | ||
var Address1 : String = " 5442 Appaloosa Way" | ||
var Address2 : String = "First Floor" | ||
var City : String = "Loma Linda" | ||
var State : String = "Missouri" | ||
var Postalcode : String = "64804" | ||
var Country: String = "USA" | ||
var Sender:String = "Annie" | ||
var Frontimage : String = "Picture of Roo" | ||
var Backtext : String = "\nHi Leah\n Here is a photo of ROO\n Love\n Leah\n" | ||
var Accentimage : String = " NO Accentimage" | ||
var Backimage : String = "NO Backimage" | ||
|
||
|
||
@IBOutlet var webview: UIWebView! | ||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
|
||
// First User Object | ||
// Generate CSV file | ||
let user1:NSMutableDictionary = NSMutableDictionary() | ||
user1.setObject("vignesh", forKey: "name" as NSCopying); | ||
user1.setObject("[email protected]", forKey: "email" as NSCopying); | ||
|
||
user1.setObject(DMID, forKey: "DMID" as NSCopying); //required | ||
user1.setObject(RECORDID, forKey: "RecordID" as NSCopying); //required | ||
user1.setObject(First, forKey: "First" as NSCopying); //required | ||
user1.setObject(Last, forKey: "Last" as NSCopying); //required | ||
user1.setObject(Company, forKey: "Company" as NSCopying); //required | ||
user1.setObject(Address1, forKey: "Address1" as NSCopying); //required | ||
user1.setObject(Address2, forKey: "Address2" as NSCopying); //optional | ||
user1.setObject(City, forKey: "City" as NSCopying); //required | ||
user1.setObject(State, forKey: "State" as NSCopying); //required | ||
user1.setObject(Postalcode, forKey: "Postalcode" as NSCopying); //required | ||
user1.setObject(Country, forKey: "Country" as NSCopying); //optional | ||
user1.setObject(Sender, forKey: "Sender" as NSCopying); //optional | ||
user1.setObject(Frontimage, forKey: "Frontimage" as NSCopying); //required | ||
user1.setObject(Backtext, forKey: "Backtext" as NSCopying); //optional | ||
user1.setObject(Accentimage, forKey: "Accentimage" as NSCopying); //optional | ||
user1.setObject(Backimage, forKey: "Backimage" as NSCopying); //optional | ||
let user2:NSMutableDictionary = NSMutableDictionary() | ||
user2.setObject("vinoth", forKey: "name" as NSCopying); | ||
user2.setObject("[email protected]", forKey: "email" as NSCopying); | ||
|
||
|
||
// CSV rows Array | ||
let data:NSMutableArray = NSMutableArray() | ||
data.add(user1); | ||
|
||
|
||
let filePath:String = SwiftCSVExport.exportCSV("userlist1",fields: ["DMID", "RecordID", "First", "Last", "Company","Address1", "Address2", "City", "State", "Postalcode", "Country", "Sender","Frontimage", "Backtext", "Accentimage", "Backimage"],values: data); | ||
data.add(user2); | ||
|
||
let filePath:String = SwiftCSVExport.exportCSV("userlist",fields: ["name", "email"],values: data); | ||
print(filePath) | ||
|
||
let request = NSURLRequest(url: URL(fileURLWithPath: filePath) ) | ||
webview.loadRequest(request as URLRequest) | ||
|
||
// | ||
let fileDetails = readCSV(filePath); | ||
if fileDetails.allKeys.count > 0 { | ||
|
@@ -87,7 +57,5 @@ class ViewController: UIViewController { | |
super.didReceiveMemoryWarning() | ||
// Dispose of any resources that can be recreated. | ||
} | ||
var csvText = "DMID, RecordID, First, Last, Street,Apt., City, State, Postalcode\n" | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters