public void TestWriteRow() { var dt = GetTestData(); string dataFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "file", "onesheetfile.xlsx"); NPOIOperator oper = new NPOIOperator(dataFilePath, true); var sheet = oper.GetSheet("Sheet3"); var row = sheet.CreateRow(1); oper.WriteRow(row, dt.Columns, dt.Rows[1]); var readDT = oper.ReadSheet(sheet, false, 1); Assert.AreEqual(1, readDT.Rows.Count); Assert.AreEqual("李四", readDT.Rows[0]["列2"].ToString()); }