
帮帮忙,写的时候代码没有报错但是运行的时候突然蹦出来这个😭我找不到我的引用有什么错误,有没有帮帮忙,我纯纯的新😭
不是引用错误,是你有变量是null了
看下是不是myApp 为空了
不建议使用这种方式容易出错,可以去nuget下载下面两个包

读取代码
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);//注意这里写路径时要用c:\而不是c:
openFileDialog.Filter = "EXCEL文件|.xls|所有文件|.*";
openFileDialog.FilterIndex = 1;DataTable dt_temp=new DataTable(),dt1;if (openFileDialog.ShowDialog() == DialogResult.OK){//dt = ExcelRead.ThreadReadExcel(openFileDialog.FileName);using (var stream = File.Open(openFileDialog.FileName, FileMode.Open, FileAccess.Read)){// Auto-detect format, supports:// - Binary Excel files (2.0-2003 format; *.xls)// - OpenXml Excel files (2007 format; *.xlsx, *.xlsb)using (var reader = ExcelReaderFactory.CreateReader(stream)){var result = reader.AsDataSet();// The result of each spreadsheet is in result.Tablesdt_temp = result.Tables[0];}}} //dt_temp.Columns.Remove("列名称");
for (int i = dt_temp.Columns.Count - 1; i > 13; i--)
{ dt_temp.Columns.RemoveAt(i); }