Exemplo n.º 1
0
        public void WriteExcel()
        {
            using (ExcelHelper excel = new ExcelHelper("abcds.xls"))
            {
                excel.Hdr = "YES";
                excel.Imex = "0";
                Dictionary<string, string> tableDefinition = new Dictionary<string, string>();
                tableDefinition.Add("Name", "ntext");
                tableDefinition.Add("Age", "ntext");
                tableDefinition.Add("Class", "ntext");

                excel.WriteTable("Student", tableDefinition);

                StringBuilder sb = new StringBuilder();
            //                //for (int i = 0;i <100; i++)
            //                //{
                    sb.Append(" insert into [Student] (Name,Age,Class) values (");
            ////                }
            //
                    sb.Append("'"); sb.Append("a"); sb.Append("',");
                    sb.Append("'"); sb.Append("b"); sb.Append("',");
                    sb.Append("'"); sb.Append("c"); sb.Append("'");
                    sb.Append(")");
                    Console.WriteLine(sb.ToString());
                    excel.ExecuteCommand(sb.ToString());

            //                excel.ExecuteCommand(sql);
            }
        }