使用saveFileDialog导出gridControl中 gridView里的数据

   private void button1_Click(object sender, EventArgs e)
        {
    
    
            saveFileDialog1.ShowDialog();
            string filepath = saveFileDialog1.FileName.Trim();
            string fstyle = filepath.Substring(filepath.LastIndexOf('.') + 1, filepath.Length - filepath.LastIndexOf('.') - 1).ToUpper();
            if (filepath != string.Empty)
            {
    
    
                if (fstyle == "XLS")
                {
    
    
                    gridView1.ExportToXls(filepath);
                }
                else if (fstyle == "XLSX")
                {
    
    
                    gridView1.ExportToXlsx(filepath);
                }
            }
        }

猜你喜欢

转载自blog.csdn.net/varcad/article/details/103609327