Пример #1
0
        public void TestCreatExcel(string fileName)
        {
            AsposeExcelApplication x = new AsposeExcelApplication(fileName);
            int count = x.Workbook.Worksheets.Count;

            Assert.True(count > 0);
        }
Пример #2
0
        public void TestCreateSheet()
        {
            string name = Guid.NewGuid().ToString("N").Substring(0, 10);

            workbook.CreateSheet(name);
            workbook.Save();
            string path = workbook.Workbook.FileName;

            workbook.Workbook.Dispose();
            AsposeExcelApplication workbooktemp = new AsposeExcelApplication(path);
            bool x = workbooktemp.Workbook.Worksheets.Find(t => t.Name.Equals(name)) != null;

            Assert.True(x);
        }
Пример #3
0
        public void TestSetValueInCell(string sheetNmae, int rowIndex, int ColumnIndex, object value)
        {
            AsposeExcelApplication aea = new AsposeExcelApplication(fileName);

            if (value.Equals("datetime"))
            {
                var dateValue = DateTime.Now;
                aea.SetCellValue(sheetNmae, rowIndex, ColumnIndex, dateValue);
                Assert.Equal(dateValue.ToShortDateString(), aea.GetCellValue(sheetNmae, rowIndex, ColumnIndex).ToString());
            }
            else
            {
                aea.SetCellValue(sheetNmae, rowIndex, ColumnIndex, value);
                Assert.Equal(value.ToString(), aea.GetCellValue(sheetNmae, rowIndex, ColumnIndex).ToString());
            }
        }