Exemplo n.º 1
0
        public void TestReadTitleWithRow()
        {
            string dataFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "file", "forread.xlsx");
            NPOIOperator oper = new NPOIOperator(dataFilePath, true);
            var sheet = oper.GetSheet("Sheet1");
            var firstRow = sheet.GetRow(0);

            var cols = oper.ReadTitle(firstRow);
            Assert.AreEqual(5, cols.Length);
            Assert.AreEqual("出生日期", cols[4].ColumnName);
        }
Exemplo n.º 2
0
        public void TestWriteTitleWithRow()
        {
            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(0);
            oper.WriteTitle(row, dt.Columns);

            var cols = oper.ReadTitle(sheet);
            Assert.AreEqual(5, cols.Length);
            Assert.AreEqual("姓名", cols[1].ColumnName);
        }