我们这边用的是SpreadforWPF-Silverlight-v8.1 导出的代码是{
private void btnExcel_Click(object sender, RoutedEventArgs e)
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "Excel File (.xls,.xlsx)|*.xls; *.xlsx";
saveFileDialog.FilterIndex = 1;
bool? userClickOk = saveFileDialog.ShowDialog();
if (userClickOk == true)
{
var stream = saveFileDialog.OpenFile();
var fileName = saveFileDialog.SafeFileName;
var fileFormat = ExcelFileFormat.XLS;
if (fileName.EndsWith(".xlsx"))
fileFormat = ExcelFileFormat.XLSX;
else
fileFormat = ExcelFileFormat.XLS;
this.SpreadTable.SaveExcel(stream, fileFormat, GetSaveFlag());
stream.Close();
}
}
private ExcelSaveFlags GetSaveFlag()
{
var flagText = ExcelSaveFlags.NoFlagsSet.ToString();
var result = ExcelSaveFlags.NoFlagsSet;
Enum.TryParse<ExcelSaveFlags>(flagText, true, out result);
return result;
}
} |
|