예제 #1
0
        public void TestExcelGeneration()
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            ExcelOpenXML excelDoc = new ExcelOpenXML(true, ConfigurationManager.AppSettings["TempFileDirectory"].ToString());
            excelDoc.Open(Directory.GetCurrentDirectory() + "\\Expense Czar Report.xlsx");
            excelDoc.ActiveSheetByName = "Expense Czar Report";

            //for (int i = 12; i <= 19; i++)
            //{
            //    for (int j = 2; j <= 7; j++)
            //    {
            //        excelDoc.SetCellStyle(i, IndexedColumnToNamedColumn(j), "[$₡-140A]#,##0.00");
            //    }
            //}

            excelDoc.ActiveSheetByName = "Data";

            excelDoc.SetStringCellValue(2, "A", "asd");
            excelDoc.SetStringCellValue(2, "B", "asd");
            excelDoc.SetStringCellValue(2, "C", "asd");
            excelDoc.SetStringCellValue(2, "D", "asd");
            excelDoc.SetStringCellValue(2, "E", "asd");
            excelDoc.SetStringCellValue(2, "F", "asd");
            excelDoc.SetNumericCellValue(2, "G", 1.123);
            excelDoc.SetNumericCellValue(2, "H", 1.123);
            excelDoc.SetNumericCellValue(2, "I", 1.123);
            excelDoc.SetNumericCellValue(2, "J", 1.123);
            excelDoc.SetNumericCellValue(2, "K", 1.123);
            excelDoc.SetNumericCellValue(2, "L", 1.123);

            excelDoc.SetPivotTableReference("Expense Czar Report", "A1:L2", "Data");

            excelDoc.Save("D:\\Test" + DateTime.Now.ToFileTimeUtc().ToString() + ".xlsx");
            excelDoc.Close();

            stopWatch.Stop();

            //Console.WriteLine("Time taken: " + stopWatch.Elapsed.ToString());

            Assert.IsTrue(true);
        }
예제 #2
0
        public void TestExcelGeneration()
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            ExcelOpenXML excelDoc = new ExcelOpenXML(true, ConfigurationManager.AppSettings["TempFileDirectory"].ToString());
            excelDoc.Open(Directory.GetCurrentDirectory() + "\\Budget Originator - Owner Report (Functional Department).xlsx");
            excelDoc.ActiveSheetByName = "Budget Originator - Owner";

            //for (int i = 12; i <= 19; i++)
            //{
            //    for (int j = 2; j <= 7; j++)
            //    {
            //        excelDoc.SetCellStyle(i, IndexedColumnToNamedColumn(j), "[$₡-140A]#,##0.00");
            //    }
            //}

            excelDoc.ActiveSheetByName = "Data";

            excelDoc.SetStringCellValue(2, "A", "asd");
            excelDoc.SetStringCellValue(2, "B", "asd");
            excelDoc.SetStringCellValue(2, "C", "asd");
            excelDoc.SetStringCellValue(2, "D", "asd");
            excelDoc.SetStringCellValue(2, "E", "asd");
            excelDoc.SetStringCellValue(2, "F", "asd");
            excelDoc.SetStringCellValue(2, "G", "asd");
            excelDoc.SetStringCellValue(2, "H", "asd");
            excelDoc.SetStringCellValue(2, "I", "asd");
            excelDoc.SetStringCellValue(2, "J", "asd");
            excelDoc.SetStringCellValue(2, "K", "asd");
            excelDoc.SetNumericCellValue(2, "L", 1.123);
            excelDoc.SetNumericCellValue(2, "M", 1.123);
            excelDoc.SetNumericCellValue(2, "N", 1.123);

            excelDoc.SetStringCellValue(3, "A", "asd");
            excelDoc.SetStringCellValue(3, "B", "asd");
            excelDoc.SetStringCellValue(3, "C", "asd");
            excelDoc.SetStringCellValue(3, "D", "asd");
            excelDoc.SetStringCellValue(3, "E", "asd");
            excelDoc.SetStringCellValue(3, "F", "asd");
            excelDoc.SetStringCellValue(3, "G", "asd");
            excelDoc.SetStringCellValue(3, "H", "asd");
            excelDoc.SetStringCellValue(3, "I", "asd");
            excelDoc.SetStringCellValue(3, "J", "asd");
            excelDoc.SetStringCellValue(3, "K", "oph");
            excelDoc.SetNumericCellValue(3, "L", 1.123);
            excelDoc.SetNumericCellValue(3, "M", 1.123);
            excelDoc.SetNumericCellValue(3, "N", 1.123);

            excelDoc.SetStringCellValue(4, "A", "asd");
            excelDoc.SetStringCellValue(4, "B", "asd");
            excelDoc.SetStringCellValue(4, "C", "asd");
            excelDoc.SetStringCellValue(4, "D", "asd");
            excelDoc.SetStringCellValue(4, "E", "asd");
            excelDoc.SetStringCellValue(4, "F", "asd");
            excelDoc.SetStringCellValue(4, "G", "asd");
            excelDoc.SetStringCellValue(4, "H", "asd");
            excelDoc.SetStringCellValue(4, "I", "asd");
            excelDoc.SetStringCellValue(4, "J", "asd");
            excelDoc.SetStringCellValue(4, "K", "bhd");
            excelDoc.SetNumericCellValue(4, "L", 1.123);
            excelDoc.SetNumericCellValue(4, "M", 1.123);
            excelDoc.SetNumericCellValue(4, "N", 1.123);

            excelDoc.SetPivotTableReference("Budget Originator / Owner Report", "A1:N4", "Data");

            IList<string> selectedItems = new List<string>();
            selectedItems.Add("oph");
            selectedItems.Add("bhd");

            IList<string> allItems = new List<string>();
            allItems.Add("oph");
            allItems.Add("bhd");
            allItems.Add("asd");

            excelDoc.SetPivotTableFilterSelectedItems("Budget Originator / Owner Report", "Functional Department", selectedItems, allItems, OpenBox.Office.ExcelOpenXML.Enums.CacheFieldType.CharacterValue);

            excelDoc.Save("D:\\Test" + DateTime.Now.ToFileTimeUtc().ToString() + ".xlsx");
            excelDoc.Close();

            stopWatch.Stop();

            //Console.WriteLine("Time taken: " + stopWatch.Elapsed.ToString());

            Assert.IsTrue(true);
        }