public void TestReadRowWithUseCellType() { var dataTable = new DataTable(); dataTable.Columns.Add("列1"); dataTable.Columns.Add("列2"); dataTable.Columns.Add("列3"); dataTable.Columns.Add("列4"); dataTable.Columns.Add("列5"); string dataFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "file", "forread.xlsx"); NPOIOperator oper = new NPOIOperator(dataFilePath, true); var sheet = oper.GetSheet(0); var row = sheet.GetRow(2); var rowData = oper.ReadRow(row, dataTable.Columns, true); Assert.AreEqual(5, rowData.Length); Assert.AreEqual("李四", rowData[1]); Assert.AreEqual(new DateTime(1984, 5, 26), rowData[4]); }
public void TestReadRow() { var dt = GetTestData(); string dataFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "file", "forread.xlsx"); NPOIOperator oper = new NPOIOperator(dataFilePath, true); var sheet = oper.GetSheet(0); var row = sheet.GetRow(2); var rowData = oper.ReadRow(row, dt.Columns); Assert.AreEqual(5, rowData.Length); Assert.AreEqual("李四", rowData[1]); Assert.AreEqual(new DateTime(1984, 5, 26), rowData[4]); }