private void Export(int type)
{
System.Windows.Forms.SaveFileDialog sfd = new SaveFileDialog();
sfd.FilterIndex = type;
sfd.Filter = "Excel文件(*.xlsx)|*.xlsx|STK文件(*.plc,*.plc3)|*.plc";
if (sfd.ShowDialog() == DialogResult.OK)
{
//FilterIndex represent which format you choose.
switch (sfd.FilterIndex)
{
case 1:
ExcelOperation myExcel = new ExcelOperation();
myExcel.DoExport(listView1, sfd.FileName);
break;
case 2:break;
}
}
}
【C#学习】保存对话框 saveDialog
![](https://img-home.csdnimg.cn/images/20240711042549.png)