Hi,
I'm trying to open a CSV file with XlsIO in a Universal Windows app and I want to databind the result to a SfDataGrid column with auto-generate columns as true. I'm struggling as I can't find any help. I'm writing this:
var picker = new FileOpenPicker();
picker.ViewMode = PickerViewMode.List;
picker.SuggestedStartLocation =
PickerLocationId.DocumentsLibrary;
picker.FileTypeFilter.Add(".csv");
var tempFile = await picker.PickSingleFileAsync();
if (tempFile != null)
{
var exStream = await tempFile.OpenStreamForReadAsync();
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
IWorkbook workbook = await application.Workbooks.OpenAsync(exStream, ",");
var data = workbook.Worksheets[0].Rows;
this.CsvGrid.ItemsSource = data;
exStream.Dispose();
}
Of course this databinding does not work and throws an exception. And because this should not be read-only, I would need to generate an ObservableCollection from the CSV's rows but I can't figure out how to extract a collection of rows from the worksheet. Any help please?