Exemple #1
0
        /// <summary>
        /// Input array:    a1      b1          c1                  Output: []      []                  c1
        ///                 1       2           3                           []      []                  3
        ///                 true    1-1-2012    true    true                TRUE    January 1, 2012     a1  b1
        ///                                                                 []      []                  1   2
        /// </summary>
        static void TestExcelCut()
        {
            ExcelDocument document = new ExcelDocument();

            string[][] array = { new string[] { "a1", "b1", "c1" }, new string[] { "1", "2", "3" }, new string[] { "true", "1-1-2012", "true", "true" } };
            document.AddArray(array, "Sheet1");
            List <List <string> > vs = document.GetRange("Sheet1", "A1", "D4");

            foreach (List <string> strs in vs)
            {
                foreach (string s in strs)
                {
                    Console.Write($"{s}, ");
                }
                Console.WriteLine();
            }

            Console.WriteLine();
            List <List <string> > a = document.CutRange("Sheet1", "A1", "B2");

            document.PasteRange("Sheet1", "C3", a);
            vs = document.GetRange("Sheet1", "A1", "D4");
            foreach (List <string> strs in vs)
            {
                foreach (string s in strs)
                {
                    Console.Write($"{s}, ");
                }
                Console.WriteLine();
            }
        }