iphone - 通过代码创建excel文件

标签 iphone objective-c ios

我需要通过 iPhone 中的代码创建 excel 文件我有两个数组,第一个数组包含水果名称,第二个数组包含该水果的图像。我想创建类似这样的 excel 文件

apple 这里是苹果的图片 芒果图片芒果在这里 . . . . . . . . . . . . . . . . . .

类似的东西请帮我创建这个

最佳答案

尝试使用以下代码生成 Excel 文件:

NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.xls", @"userdata"]]; //add our file to the path
[fileManager createFileAtPath:fullPath contents:[xlsString dataUsingEncoding:NSUTF8StringEncoding] attributes:nil]; //finally save the path (file)

记住,这里的xlsString是Excel文件的内容。您需要以这样的方式创建 xlsString:如果您插入 ,(逗号)或/t(制表符)或其他定界符。它将转到 Excel 文件中的下一个单元格。对于下一行,在 xlsString 中使用\n(换行符)。

关于iphone - 通过代码创建excel文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8722030/

相关文章:

ios - 对等端未发现哪个连接到其他网络。多点连接框架

iphone - 停止 performSelector : from being performed

ios - 如何在 Storyboard Xcode 8 中启用自动布局

ios - 存储大量 bool 变量的最佳方法?

ios - 在 uiwebview 中单击 html 按钮时不会调用 shouldStartLoadWithRequest

ios - lsof 在 iOS 中给出 "information error: Cannot allocate memory"

iphone - 我需要做什么来为 iPhone 5 重新制作/移植我的通用 iOS 应用程序?

iphone - DOM 更改后,iPad 中的 HTML5 视频无法正常工作

iphone - 动态使用 UIViewContentModeScaleAspectFit 和 UIViewContentModeScaleAspectFill

ios - MPMusicPlayerController 不会与 Remote 交互