Esempio n. 1
0
        private void button9_Click(object sender, EventArgs e)
        {
            string tbname  = comboBox2.Text.ToString();
            string colname = comboBox5.Text.ToString();
            string csql    = " select distinct " + "[" + colname + "]" + " from " + "[" + tbname + "]";
            string sql     = " select * from  " + "[" + tbname + "]" + " where  " + "[" + colname + "]" + " = ";

            IList <string> clums = new List <string>();
            DataTable      dt    = UiServices.GetDataTableFromSQL(csql);
            int            num   = dt.Rows.Count;

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow _DataRowItem in dt.Rows)
                {
                    clums.Add(_DataRowItem[colname].ToString());
                }
            }
            string    filename = UiServices.ShowFileDialog(tbname);
            Stopwatch watch    = Stopwatch.StartNew();

            watch.Start();
            foreach (var a in clums)
            {
                string savepath = filename.Remove(filename.LastIndexOf('.')) + '_' + a + ".xlsx";

                DataTable dt1 = UiServices.GetDataTableFromSQL(sql + "'" + a + "'");
                UiServices.SaveExcel(savepath, dt1, "sheet1");
            }
            watch.Stop();
            toolStripStatusLabel1.Text      = string.Format("导出的时间为:{0}秒", watch.ElapsedMilliseconds / 1000);
            toolStripStatusLabel1.ForeColor = Color.Red;
            MessageBox.Show("导出成功");
            GC.Collect();
        }
Esempio n. 2
0
        /// <summary>
        /// 单excel,openXML
        /// </summary>
        private void button6_Click(object sender, EventArgs e)
        {
            string TableName = comboBox4.Text.ToString();
            string filename  = UiServices.ShowFileDialog(TableName);

            toolStripStatusLabel1.Text      = "导数中…";
            toolStripStatusLabel1.ForeColor = Color.Red;
            if (filename != null)
            {
                Task t = TaskExport(TableName, filename);
            }
        }
Esempio n. 3
0
 private void toolStripButton1_Click(object sender, EventArgs e)
 {
     try
     {
         string filename = UiServices.ShowFileDialog("Sheet1");
         toolStripStatusLabel1.Text      = "导数中…";
         toolStripStatusLabel1.ForeColor = Color.Red;
         Task t = TaskExport("Sheet1", sqlText.Text.ToString(), filename);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Esempio n. 4
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (textBox2.Text.ToString() == "")
            {
                MessageBox.Show("请选择需要导入的文件夹!");
            }
            DataTable[] ds       = UiServices.GetDataTableFromCSV(this.textBox2.Text.ToString(), true);
            string      filename = UiServices.ShowFileDialog("Book1");
            int         time     = UiServices.ExportExcel(ds, filename);

            GC.Collect();
            toolStripStatusLabel1.Text      = string.Format("执行操作时间为:{0}秒", time);
            toolStripStatusLabel1.ForeColor = Color.Red;
        }
Esempio n. 5
0
 //导出EXCEL模板文件
 private void btnTP_Click(object sender, EventArgs e)
 {
     if (comboBox1.Text.ToString() == "")
     {
         MessageBox.Show("请选择需要导出模板的表名!");
     }
     else
     {
         string TableName = comboBox1.Text.ToString();
         string filename  = UiServices.ShowFileDialog(TableName);
         int    time      = UiServices.ExportTemplate(TableName, filename);
         toolStripStatusLabel1.Text      = string.Format("导出的时间为:{0}秒", time);
         toolStripStatusLabel1.ForeColor = Color.Red;
         MessageBox.Show("导出成功!");
     }
 }
Esempio n. 6
0
 //导出数据
 private void btnDtout_Click(object sender, EventArgs e)
 {
     if (listBox1.Items.Count < 1)
     {
         MessageBox.Show("请选择需要导入的表名!");
     }
     else
     {
         IList <string> SheetNames = new List <string>();
         foreach (var item in listBox1.Items)
         {
             SheetNames.Add(item.ToString());
         }
         string filename = UiServices.ShowFileDialog(SheetNames[0]);
         toolStripStatusLabel1.Text      = "导数中…";
         toolStripStatusLabel1.ForeColor = Color.Red;
         if (filename != null)
         {
             Task t = TaskExport(SheetNames, filename);
         }
     }
 }