1.最近项目需要说要把数据从沙盒中读取出来,我当时就懵逼里面都是数据库文件呀,但是里面不是全部的数据需要知道呀,就使用了LibXL.framework这个execl的框架,来导出出来了!!
2.使用LibXL.framework的要使用的动态链接库:
3.在项目中使用的东西直接上代码了:
//分享
- (IBAction)onClickShareBtn:(id)sender {
BookHandlebook =xlCreateBook();
SheetHandlesheet =xlBookAddSheet(book,"Sheet1",NULL);
//第一个参数是代表插入那个表,第二个参数是第几行(默认从0开始),第三个是第几列(默认是从0开始)
xlSheetWriteStr(sheet,1,0,"名称",0);
xlSheetWriteStr(sheet,1,1,"价格",0);
for(inti =0; i
Book*book =self.dataArray[i];
xlSheetWriteStr(sheet, i+2,0, [book.namecStringUsingEncoding:NSUTF8StringEncoding],0);
xlSheetWriteStr(sheet, i+2,1, [book.pricecStringUsingEncoding:NSUTF8StringEncoding] ,0);
}
NSString*documentPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES)objectAtIndex:0];
NSString*Fname = [@"book"stringByAppendingString:@".xls"];
NSString*filename = [documentPathstringByAppendingPathComponent:Fname]
;
NSLog(@"fileName:%@",filename);
xlBookSave(book,[filenameUTF8String]);
xlBookRelease;
UIActivityViewController*activityVC = [[UIActivityViewControlleralloc]initWithActivityItems:@[[NSURLfileURLWithPath:filename]]applicationActivities:nil];
activityVC.completionHandler= ^(NSString*activityType,BOOLcompleted) {
NSLog(@"complete share activityType:%@, completed:%d", activityType, completed);
};
[selfpresentViewController:activityVCanimated:YEScompletion:nil];
}
最后就行了你可以发送qq和微信和备忘录里面查看文件了!!!