XlsxReaderWriter
XlsxReaderWriter copied to clipboard
Can't create new worksheet by Copying worksheet
Here is the exception occurred when I tried to copy work sheet. I hope this issue will be fixed soon because I use this code in my current project.
2017-01-16 05:28:55.221 XlsxCreation[24421:3215698] *** Assertion failure in -[BRARelationship targetFormat], /Volumes/Data/Sample/ios/XlsxCreation/Pods/XlsxReaderWriter/XlsxReaderWriter/BRARelationship.m:70 2017-01-16 05:28:55.242 XlsxCreation[24421:3215698] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[BRARelationship targetFormat] is not implemented in BRARelationship' *** First throw call stack: ( 0 CoreFoundation 0x00000001077c034b __exceptionPreprocess + 171 1 libobjc.A.dylib 0x000000010545521e objc_exception_throw + 48 2 CoreFoundation 0x00000001077c4442 +[NSException raise:format:arguments:] + 98 3 Foundation 0x0000000104febe4d -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195 4 XlsxCreation 0x0000000104de78fd -[BRARelationship targetFormat] + 301 5 XlsxCreation 0x0000000104de7bfb -[BRARelationship setParentDirectory:] + 139 6 XlsxCreation 0x0000000104de8d2b -[BRARelationships setParentDirectory:] + 859 7 XlsxCreation 0x0000000104de7ca9 -[BRARelationship setParentDirectory:] + 313 8 XlsxCreation 0x0000000104de8d2b -[BRARelationships setParentDirectory:] + 859 9 XlsxCreation 0x0000000104de7ca9 -[BRARelationship setParentDirectory:] + 313 10 XlsxCreation 0x0000000104de8d2b -[BRARelationships setParentDirectory:] + 859 11 XlsxCreation 0x0000000104de4934 -[BRAOfficeDocumentPackage save] + 548 12 XlsxCreation 0x0000000104de53b1 -[BRAOfficeDocumentPackage saveAs:] + 321 13 XlsxCreation 0x0000000104db066e -[ViewController OnCreateXlsx:] + 734 14 UIKit 0x0000000105e815b8 -[UIApplication sendAction:to:from:forEvent:] + 83 15 UIKit 0x0000000106006edd -[UIControl sendAction:to:forEvent:] + 67 16 UIKit 0x00000001060071f6 -[UIControl _sendActionsForEvents:withEvent:] + 444 17 UIKit 0x00000001060060f2 -[UIControl touchesEnded:withEvent:] + 668 18 UIKit 0x0000000105eeece1 -[UIWindow _sendTouchesForEvent:] + 2747 19 UIKit 0x0000000105ef03cf -[UIWindow sendEvent:] + 4011 20 UIKit 0x0000000105e9d63f -[UIApplication sendEvent:] + 371 21 UIKit 0x000000010668f71d __dispatchPreprocessedEventFromEventQueue + 3248 22 UIKit 0x00000001066883c7 __handleEventQueue + 4879 23 CoreFoundation 0x0000000107765311 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 24 CoreFoundation 0x000000010774a59c __CFRunLoopDoSources0 + 556 25 CoreFoundation 0x0000000107749a86 __CFRunLoopRun + 918 26 CoreFoundation 0x0000000107749494 CFRunLoopRunSpecific + 420 27 GraphicsServices 0x0000000109ee5a6f GSEventRunModal + 161 28 UIKit 0x0000000105e7f964 UIApplicationMain + 159 29 XlsxCreation 0x0000000104db09af main + 111 30 libdyld.dylib 0x0000000105a5268d start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException
Try to download the lib from git, not cocoapods. Cocoapods isn't up to date.
ok, Thanks. I will try
I added lib to my project and compiled but same issue when used cocoapods. Please reply me with solution. Thanks.
I attached the xlsx file that I am working. I need to create many sheets by copying "template" sheet. Please try yourself or let me know how to fix the issue.
Look forward to hearing from you soon. Thanks.
Please, post your code here. You've said that this error happened while copying sheet but your stack is not saying that.
Here is the code.
NSString *documentPath = [[NSBundle mainBundle] pathForResource:@"template.xlsx" ofType:nil]; BRAOfficeDocumentPackage *spreadsheet = [BRAOfficeDocumentPackage open:documentPath];
BRAWorksheet *workSheet = spreadsheet.workbook.worksheets[0];
BRAWorksheet *copiedWorkSheet = [spreadsheet.workbook createWorksheetNamed:@"copied" byCopyingWorksheet:workSheet];
NSString *fullPath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"result.xlsx"];
[spreadsheet saveAs:fullPath];
Did you try to copy with my template excel file? Please try to do with it.
Hi, René I am waiting for you reply. When can you let me know the solution? Thanks.
Hey. This support is not available anymore??
Hi @emil-lind, I'm trying hard to give as much time as I can to this project, but I'm just someone who is sharing is work. I'm not paid for that and it's not my main activity. I'll try to give you an answer as fast as I'll can, but please be patient.
@emil-lind One thing I found when using the library is that copying workbook is not very efficient and taking a lot of memory as you actually open the file (so actively read content, unzip, etc...) Then close the file, file being rebuild, etc.
I used a different approach where I am actually manually copying the template file using NSFileManager
provided method to the destination where I want my file copied.xlsx
then opening it to perform changes to it.
It is the most efficient approach I found.