Beispiel #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            DataTable tableOutput = null;
            var adapter = new ExcelWorkBookAdaptor();
            adapter.Open("C:/temp/Book1.xlsx");
            adapter.Show();
            var xlRangeAdapter = new ExcelRangeToDataTableAdapter(adapter[0]);
            Point topLeft = new Point(1, 1);
            Point bottomRight = new Point(2, 20);

            try
            {
                tableOutput = xlRangeAdapter.ReadTable("A1:B21");
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                adapter.CloseNoSave();
            }

            if (null != tableOutput)
            {
                adapter = new ExcelWorkBookAdaptor();
                adapter.NewBook();
                adapter.Show();
                var tableAdapter = new DataTableToExcelAdapter(adapter[0], tableOutput);
                tableAdapter.Write(topLeft);

                //adapter.SaveAndClose("C:/temp/Book2.xlsx");
            }
        }
Beispiel #2
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            // TODO: Implement Functionality Here

            //adaptor.OpenExisting(@"C:\Test Excel\Book1.xlsx");

            var data = new List<double>();
            data.Add(10);
            data.Add(10);
            data.Add(10);
            data.Add(10);
            data.Add(10);

            var data2 = new List<string>();
            data2.Add("hello");
            data2.Add("hello");
            data2.Add("hello");
            data2.Add("hello");
            data2.Add("hello");
            data2.Add("hello");
            data2.Add("hello");
            data2.Add("hello");
            data2.Add("hello");
            data2.Add("hello");
            data2.Add("hello");
            data2.Add("hello");
            data2.Add("hello");

            var adaptor = new ExcelWorkBookAdaptor();

            adaptor.NewBook();

            var listAdapter = new ListToExcelTableAdaptor<string>(adaptor[0], data2);
            listAdapter.Write(new ExcelCellCoordinate(10, 10), 2);

            var format = new ExcelRangeTableStyle(adaptor[0], new ExcelCellCoordinate(10, 10), new ExcelCellCoordinate(15, 15)) { FirstRowContainHeaders = true };
            format.Execute();

            adaptor.Show();

            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);

            adaptor.SaveAndClose(@"C:\Test Excel\Book2.xlsx");
        }
Beispiel #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            var adaptor = new ExcelWorkBookAdaptor();

            adaptor.NewBook();

            Point topLeft = new Point(1, 1);
            Point bottomRight = new Point(this.grid.ScenarioData.Columns.Count, this.grid.ScenarioData.Rows.Count + 1);

            var tableAdapter = new DataTableToExcelAdapter(adaptor[0], this.grid.ScenarioData);
            tableAdapter.Write(topLeft);

            var format = new ExcelRangeTableStyle(adaptor[0], topLeft, bottomRight) { FirstRowContainHeaders = true };
            format.Execute();

            adaptor.Show();
        }