private void daochu_Click(object sender, RoutedEventArgs e)
{
System.Windows.Controls.DataGrid DataGrid = dataGrid1;
string file = "C:Users\\Administrator\\Desktop\\qb";
Export(DataGrid, file);
}
public static void Export(System.Windows.Controls.DataGrid dataGrid, string _fileName)
{
System.Data.DataTable dt = new System.Data.DataTable();
for (int i = 0; i < dataGrid.Columns.Count; i++)
{
if (dataGrid.Columns[i].Visibility == System.Windows.Visibility.Visible)//只导出可见列
{
dt.Columns.Add(dataGrid.Columns[i].Header.ToString());//构建表头
1