回复 2楼gw0506的帖子
- <c1:C1FlexGrid x:Name="dgList" Grid.Row="1" AutoGenerateColumns="False" SelectionMode="Row">
- <c1:C1FlexGrid.Columns>
- <c1:Column Header="交易流水号" Width="120" Binding = "{Binding AAE072}" />
- <c1:Column Header="就诊医院编号" Width="100" Binding = "{Binding AKB020}" />
- <c1:Column Header="定点单位编号" Width="100" Binding = "{Binding AKB026}" />
- <c1:Column Header="定点单位名称" Width="100" Binding = "{Binding AKB027}" />
- </c1:C1FlexGrid.Columns>
- </c1:C1FlexGrid>
复制代码- //导出文件
- void btnExport_Click(object sender, RoutedEventArgs e)
- {
- var dlg = new SaveFileDialog();
- dlg.DefaultExt = "csv";
- dlg.Filter =
- "Comma Separated Values (*.csv)|*.csv|" +
- "Text File (*.txt)|*.txt";
- if (dlg.ShowDialog().Value)
- {
- using (var s = dlg.OpenFile())
- {
- // dlg.FilterIndex is not working properly (SL bug) so we check
- // the file extension to chose the proper save format.
- var ext = System.IO.Path.GetExtension(dlg.SafeFileName).ToLower();
- switch (ext)
- {
- case ".csv":
- dgList.Save(s, FileFormat.Csv, SaveOptions.SaveColumnHeaders);
- break;
- case ".txt":
- dgList.Save(s, FileFormat.Text, SaveOptions.Formatted);
- break;
- default:
- dgList.Save(s, FileFormat.Csv, SaveOptions.Formatted);
- break;
- }
- }
- }
- }
复制代码
这个是我的导出文件的代码,导出文件乱码。 |