File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -262,6 +262,18 @@ csv = Roo::CSV.new("mytsv.tsv", csv_options: {col_sep: "\t"})
262
262
csv = Roo ::CSV .new (" mycsv.csv" , csv_options: {encoding: Encoding ::ISO_8859_1 })
263
263
```
264
264
265
+ You can also open csv files through the Roo::Spreadsheet class (useful if you accept both CSV and Excel types from a user file upload, for example).
266
+
267
+ ``` ruby
268
+ # Load a spreadsheet from a file path
269
+ # Roo figures out the right parser based on file extension
270
+ spreadsheet = Roo ::Spreadsheet .open (csv_or_xlsx_file)
271
+
272
+ # Load a csv and auto-strip the BOM (byte order mark)
273
+ # csv files saved from MS Excel typically have the BOM marker at the beginning of the file
274
+ spreadsheet = Roo ::Spreadsheet .open (" mycsv.csv" , { csv_options: { encoding: ' bom|utf-8' } })
275
+ ```
276
+
265
277
## Upgrading from Roo 1.13.x
266
278
If you use `` .xls `` or Google spreadsheets, you will need to install `` roo-xls `` or `` roo-google `` to continue using that functionality.
267
279
You can’t perform that action at this time.
0 commit comments