Using Expo.FileSystem to read spreadsheet files

Can we use Expo.FileSystem to read spreadsheet files? I’m planning to get data as JSON using GitHub - SheetJS/sheetjs: 📗 SheetJS Community Edition -- Spreadsheet Data Toolkit but files were unable to read.
Also is there support for encoding type of ASCII while reading file as string?

Hey @i8e4,

Unfortunately, no support for ASCII encoding type right now, and I am looking into if readAsStringAsync supports xlsx files

-Charlie

Thanks @charliecruzan, also I was planning to use GitHub - SheetJS/sheetjs: 📗 SheetJS Community Edition -- Spreadsheet Data Toolkit. Is it possible with current expo?

For a managed project- rule of thumb is if you have to run react-native link, you can’t use that API.

BUT if you’re using the bare workflow, then you can use anything that a regular React-Native app can use (because you are working with a regular React Native app :slight_smile: )

@charliecruzan yeah that, but isn’t result of expo FileSystem same as result of react-native-fs, except in ascii i.e.? If not, is there any other workaround for this?

Below is a potential solution I find:
I don’t implement it at the end, as I found in my need (import some static data) , it’s easier to just convert xlsx file to json and import it directly.

FileSystem.readAsStringAsync(fileUri, {encoding: FileSystem.EncodingTypes.Base64}).then(b64 => XLSX.read(b64, {type: “base64”})).then(wb => { /* process the workbook here */ });

for “fileUri”, please check the document of FileSystem:

And also, in order to use {encoding: FileSystem.EncodingTypes.Base64}, expo SDK 31.0.0 or later version is needed.

for more info on this topic, pls check:

https://github.com/SheetJS/js-xlsx/blob/master/demos/react/react-native.js

for solutions for problems with upgrading from SDK 27.0.0 to SDK 32.0.0:
Problem Upgrading to SDK 31 (Cannot Find Babel Plugin ‘transform-react-jsx-source’)
[SDK32] undefined is not an object (evaluating ‘_expo2.default.KeepAwake’) #3152

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.