统一解析xlsx文件

时间:2019-07-08 08:26:21

标签: c# android unity3d xlsx exceldatareader

我使用以下代码来解析XLSX文件。

private IExcelDataReader GetExcelDataReaderForFile(string filePath)
{
    FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read);

    // Create the excel data reader
    IExcelDataReader excelReader;

    excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
    // Close the stream
    stream.Close();

    // First row are columns names
    excelReader.IsFirstRowAsColumnNames = true;

    return excelReader;
}

我正在Android上运行此代码。该路径取决于Application.persistentDataPath。这里的问题是我收到以下奇怪的错误

  

拒绝访问路径“ / tmp”。

如何解决?还是有其他方法可以解析Android中的xlsx文件?

1 个答案:

答案 0 :(得分:1)

您要在驱动器的根目录下请求文件/目录。

您应该使用./tmp(请注意。),或者如果您坚持使用Application.persistentDataPath + "/tmp"

相关问题