Firstly, I created an excel file with 2 columns and 20 rows. I turned it into a table. I tried this code in Visual Studio:
ExcelDataSource myExcelSource = new ExcelDataSource();
myExcelSource.FileName = @"C:UsersFardinDesktopBook1.xlsx";
ExcelWorksheetSettings worksheetSettings = new ExcelWorksheetSettings("Sheet1", "A1:B20");
myExcelSource.SourceOptions = new ExcelSourceOptions(worksheetSettings);
myExcelSource.SourceOptions.SkipEmptyRows = false;
myExcelSource.SourceOptions.UseFirstRowAsHeader = true;
myExcelSource.Fill();
pivotGridControl1.DataSource = myExcelSource;
But, I have runtime error at last line. It says:
System.NullReferenceException: 'Object reference not set to an instance of an object.'
question from:
https://stackoverflow.com/questions/65839915/how-to-select-data-source-programmatically-for-xtrapivotgrid-devexpress 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…