Hi
hi is there a frame work in Cocoa to export data from ata levied to Excel or Numbers ? and is there something similar exporting to pdf ?
--
Kindest Regards
Idid not find for Excel.
I wrote my own export (and import) functions to CSV (and even SYLK).
Essentially, you create a String from data and save to a text file ; then import in Excel as CSV.
Here is an idea of how I did it
func buildDataForCSV() -> String? {
var fullText = ""
// 1. Values containing decimal separator (eg ,) must be in quotes
let nf = NumberFormatter()
var nfDecimalSeparator = ""
if let nfSeparator = nf.decimalSeparator {
nfDecimalSeparator = nfSeparator
}
func enquote(_ aStr: String) -> String {
let separatorMark = separateurChar.first! // separator selected for CSV
if nfDecimalSeparator == "" { return aStr } // No change
var newString = aStr
if aStr.contains(separatorMark) {
newString = enclosingQuote + aStr + enclosingQuote // 1,2 becomes "1,2"
}
return newString
}
// 2. Loop through cells
// create a line of text for the cell
var aLine = ""
// Loop through all fields of the cell
aLine += separateurChar + enquote(field.text)
fullText += aLine + "\n"
// Load next cell
print("CSV En construction\n", fullText) // For test
return fullText
}