Ejemplo n.º 1
0
        public void TestDump2x3()
        {
            Calcul calcul = new Calcul();
            Size   sz     = new Size(2, 3);
            List <IList <int> > positionsGagnantes = new List <IList <int> >();

            positionsGagnantes.Add(new int[] { 0, 1, 2 });
            positionsGagnantes.Add(new int[] { 0, 1, 3 });
            int handler = calcul.ComputeDock(sz, 3, positionsGagnantes);

            List <List <string> > dump = calcul.DumpDock(handler);
            FileInfo fi = new FileInfo("Dump2x3.xlsx");

            using (ExcelPackage excel = new ExcelPackage())
            {
                ExcelWorksheet ws = excel.Workbook.Worksheets.Add("dump");
                int            row, col;
                row = 1;
                foreach (List <string> itemRow in dump)
                {
                    col = 1;
                    foreach (string item in itemRow)
                    {
                        int x, y;
                        for (int i = 0; i < item.Length; i++)
                        {
                            x = i % 2;
                            y = i / 2;
                            ExcelRange cell = ws.Cells[row + y, col + x];
                            cell.Value = "" + item[i];
                            cell.Style.Border.BorderAround(OfficeOpenXml.Style.ExcelBorderStyle.Thin);
                        }
                        col += 3;
                    }

                    row += 4;
                }
                excel.SaveAs(fi);
            }
            System.Diagnostics.Process.Start(fi.FullName);
        }