zoukankan      html  css  js  c++  java
  • Mac下使用数据库将Excel数据转换存入.plist

    记录于2013/10/26
     
    基本步骤:
    1、将Excel表格另存为.csv格式
    2、用类似TextWrangler工具将.csv文件转成UTF-8格式
    3、使用火狐插件SQLite Manager新建数据库,导入.csv文件(注意命名,最好是全英文)
    4、代码中读取数据库文件(可使用类似FMDB第三方库),代码简单如下: 
     NSString*path = [[NSBundlemainBundle]pathForResource:@"DB.sqlite"ofType:nil];
       FMDatabase*db = [FMDatabasedatabaseWithPath:path];
       
       if(![dbopen]) {
           NSLog(@"数据库打开失败");
           
           return;
        }else{
           NSLog(@"打开成功");
        }
    
    FMResultSet*results = [dbexecuteQuery:@"SELECT * FROM BatteryUTF8"];
    
        while ([results next]) {
              NSLog(@"%@     %@   %@  %@  %@  %@", [results objectForColumnIndex:0],[results objectForColumnIndex:1],[results objectForColumnIndex:2],[results objectForColumnIndex:3],[results objectForColumnIndex:4],[results objectForColumnIndex:5]);
    }

    5、代码写入plist文件,然后从沙盒中拷贝出该文件

    NSArray*doc =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
       NSString*docPath = [ docobjectAtIndex:0];
       
        [ arraywriteToFile:[docPathstringByAppendingPathComponent:@"Battery.plist"]atomically:YES];
        NSLog(@"pathPlist:%@",docPath);
     
  • 相关阅读:
    hdu 3573(数学+贪心)
    hdu 4726(贪心)
    hdu 5895(矩阵快速幂+欧拉函数)
    hdu 5894(组合数取模)
    hdu 5833(欧拉路)
    hdu 5875(单调栈)
    hdu 5877(树状数组+dfs)
    初识安卓-安装中遇到的一点坑
    第十二届湖南省省赛总结
    LuoGuP3594:[POI2015]WIL-Wilcze doły
  • 原文地址:https://www.cnblogs.com/ios-wmm/p/10216052.html
Copyright © 2011-2022 走看看