Search code examples
androidfile-handlingaspose-cells

Aspose Cell FileNotFoundException: EROFS (Read-only file system)


I get that error in the title when saving the excel file to pdf. This is in Android by the way. My code is basically like this:

Workbook workbook = new Workbook(filePath);
workbook.save(“MyPdf.pdf”, SaveFormat.PDF);

The filePath is a string that has a value of the file path of the excel file. I already granted those permissions in the manifest like what others would suggest yet I still have this error. With or without that ".pdf" extension, it will still not work.


Solution

  • Your error denotes an io issue and nothing to do with Aspose.Cells for Android via Java APIs. On Android, you need to specify sd card path for the device (where you will store both input and output files). So, make sure you are doing the right thing. See the sample code for your reference: e.g

    Sample code:

    //Get the sd card path on the device
    String sdCardPath = Environment.getExternalStorageDirectory().getPath() + File.separator;
    Workbook workbook = new Workbook(sdCardPath + "Book1.xlsx");
    workbook.save(sdCardPath + "MyFile.pdf", SaveFormat.PDF);
    

    Should you have further queries or issue, you may also post in the forums.

    PS. I am working as Support developer/ Evangelist at Aspose.