Change Excel SaveAs to Windows Forms SaveFileDialog

This commit is contained in:
Sergey Chebotar 2022-02-02 17:58:54 +03:00
parent 120eee0231
commit 7f3487d913

View File

@ -46,17 +46,22 @@ namespace RehauSku.Interface
public static void SaveWorkbookAs()
{
Workbook wb = AddIn.Excel.ActiveWorkbook;
string currentFilename = wb.FullName;
string fileFilter = "Файлы Excel (*.xls;*.xlsx;*.xlsm),*.xls;*.xlsx;*.xlsm";
Workbook workbook = AddIn.Excel.ActiveWorkbook;
object fileName = AddIn.Excel.GetSaveAsFilename(currentFilename, fileFilter);
using (SaveFileDialog dialog = new SaveFileDialog())
{
dialog.FileName = workbook.Name;
dialog.Filter = "Файлы Excel (*.xls;*.xlsx;*.xlsm)|*.xls;*.xlsx;*.xlsm";
if (fileName.GetType() == typeof(string))
wb.SaveAs(fileName);
if (dialog.ShowDialog() == DialogResult.Cancel)
{
workbook.Close(false);
}
else
wb.Close(false);
string fileName = dialog.FileName;
workbook.SaveAs(fileName);
}
}
}
}