renebigot / XlsxReaderWriter

XlsxReaderWriter is an Objective-C library for iPhone / iPad and Mac. It parses and writes MS Excel XLSX files.
MIT License
437 stars 119 forks source link

swift problem, have to cast everything and can not save #83

Open mshahoyi opened 7 years ago

mshahoyi commented 7 years ago

Hi. I am using this library in swift 4 and xcode 8.3.3. My problem is I have to cast almost everything and this is a problem because I can not save my changes to the file. The values returned are not same as the ones in the objective-C function bodies.

for example

file = BRAOfficeDocumentPackage.open(filePath)!
let worksheet: BRAWorkshhet = file.workbook.worksheets[0] //this is supposed to return a BRAWorksheet. But not for me. It returns Any for me. So the line does not compile and gives me this "can not assign value of type Any to BRAWorksheet"

So I have to cast it now let worksheet = file.workbook.worksheets[0] as! BRAWorksheet This is fine for reading from files. But writing becomes a problem because the worksheet returned by casting is a COPY of the one in the workbook, not the original reference. so when I file.save(), nothing is saved to the file. I have a feeling that I have done something wrong with importing the framework, though I followed what was written in the guide step by step, except I used cocoa pods. Can Anyone tell me the problem here?? thanks

Agm91 commented 5 years ago

Same, cannot save... Have you manage to save the .xls?