public void TestReadContentWithEndRowNumberAndUseCellType() { string dataFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "file", "forread.xlsx"); NPOIOperator oper = new NPOIOperator(dataFilePath, true); var sheet = oper.GetSheet("Sheet1"); var dataTable = new DataTable(); dataTable.Columns.Add("列1"); dataTable.Columns.Add("列2"); dataTable.Columns.Add("列3"); dataTable.Columns.Add("列4"); dataTable.Columns.Add("列5"); var readCount = oper.ReadContent(sheet, 1, 6, dataTable, true); Assert.AreEqual(6, readCount); Assert.AreEqual("猴六", dataTable.Rows[3]["列2"].ToString()); Assert.AreEqual(new DateTime(1988, 3, 14), dataTable.Rows[3]["列5"]); }
public void TestReadContentWithEndRowNumber() { string dataFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "file", "forread.xlsx"); NPOIOperator oper = new NPOIOperator(dataFilePath, true); var sheet = oper.GetSheet("Sheet1"); var dataTable = GetTestDataSchema(); var readCount = oper.ReadContent(sheet, 1, 6, dataTable); Assert.AreEqual(6, readCount); Assert.AreEqual("猴六", dataTable.Rows[3]["姓名"].ToString()); Assert.AreEqual(new DateTime(1988, 3, 14), dataTable.Rows[3]["出生日期"]); }