private void btnEx_Click(object sender, System.EventArgs e)
{
SaveFileDialog sf=new SaveFileDialog();
sf.Filter="*.txt|*.txt|*.doc|*.doc|*.xls|*.xls";
if(sf.ShowDialog()==DialogResult.OK)
{
string filename=sf.FileName;
if(sf.FilterIndex==1)
{
StreamWriter sw=new StreamWriter(filename);
foreach(DataColumn dc in dt.Columns)
{
sw.Write(dc.Caption+"\t");
}
sw.WriteLine();
foreach(DataRow r in dt.Rows)
{
for(int i=0;i<dt.Columns.Count;i++)
{
sw.Write(r[i].ToString()+"\t");
}
sw.WriteLine();
}
sw.Close();
}
}