You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I was wondering if there is a way that I can parse the XLSX file faster as I am doing a 'Flashcard' type system in my app, and do not want a time delay when the user swipes.
` func getData() {
// Collect Data
var worksheetName = ""
worksheetName = "(primaryLevel) Data"
do {
let filepath = Bundle.main.path(forResource: "Main Data", ofType: "xlsx")!
guard let file = XLSXFile(filepath: filepath) else {
fatalError("XLSX file at \(filepath) is corrupted or does not exist")
}
for wbk in try file.parseWorkbooks() {
guard let path = try file.parseWorksheetPathsAndNames(workbook: wbk)
.first(where: { $0.name == worksheetName }).map({ $0.path })
else { continue }
let sharedStrings = try file.parseSharedStrings()
let worksheet = try file.parseWorksheet(at: path)
if (topicSelRowStart + flashcardsIndex <= topicSelRowEnd) {
currentFlashcard = worksheet.cells(atRows: [UInt(topicSelRowStart + flashcardsIndex)])
.compactMap { $0.stringValue(sharedStrings) }
currentFlashcard = currentFlashcard.remove("Empty Cell")
}
}
} catch {
fatalError("\(error.localizedDescription)")
}
conceptName = currentFlashcard[2]
conceptNameLabel.numberOfLines = 3; // Dynamic number of lines
conceptNameLabel.lineBreakMode = NSLineBreakMode.byWordWrapping;
conceptNameLabel.text = conceptName
uneditedCurrentFlashcard = currentFlashcard
currentFlashcard.removeSubrange(0..<4)
let flashcardKnowledge = currentFlashcard.joined(separator: "\n")
textField.text = "\(flashcardKnowledge)"
}
`
The text was updated successfully, but these errors were encountered:
Hi @Ethan-Chew, the main optimizations that could be applied are in XMLCoder, which is the foundational library for CoreXLSX. The latter basically provides only a model layer on top of the former to make parsing work.
In the meantime, if you parse the file frequently, I'd recommend caching the parsed values either in memory, or even on disk. If you consider the latter let me know, and I'll add Encodable conformance types that require it.
Hi @MaxDesiatov, I have found another solution that works, which is to store everything in a dictonary then grab it from there when I need to use it. Thanks!
Hi, I was wondering if there is a way that I can parse the XLSX file faster as I am doing a 'Flashcard' type system in my app, and do not want a time delay when the user swipes.
` func getData() {
// Collect Data
var worksheetName = ""
worksheetName = "(primaryLevel) Data"
`
The text was updated successfully, but these errors were encountered: