如何将二进制xlsx文件转换为NSString?

时间:2017-12-18 20:08:52

标签: ios swift binary nsstring inputstream

我有一个xlsx文件,我尝试将其转换为NSString。 由于我不是专业人士,我依赖于我在不同职位上找到的内容。

我发现的是:

if let stream:InputStream = InputStream(fileAtPath: path) {

     var buf:[UInt8] = [UInt8](repeating: 0, count: 16)

     stream.open()

     while true {

          let len = stream.read(&buf, maxLength: buf.count)
          print("len \(len)")
          for i in 0..<len {
               print(String(format:"%02x ", buf[i]), terminator: "")
          }
          if len < buf.count {
               break
          }
     }
     stream.close()
}

这给了我以下输出:

len 16
50 4b 03 04 14 00 08 08 08 00 52 46 91 4b 00 00 len 16
00 00 00 00 00 00 00 00 00 00 11 00 00 00 64 6f len 16
63 50 72 6f 70 73 2f 63 6f 72 65 2e 78 6d 6c ad len 16
91 5d 4b c3 30 14 86 ef fb 2b 42 ee db 24 2d 6e len 16
23 b4 1d a2 0c 04 c5 81 93 89 77 21 3d b6 c5 e6 len 16
83 24 da f9 ef cd ba 59 51 bc f4 f2 e4 7d de 87 len 16

如果有人能给我建议我如何将其转换为NSString?

0 个答案:

没有答案