aboutsummaryrefslogtreecommitdiff
path: root/src/Interface/Dialog.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Interface/Dialog.cs')
-rw-r--r--src/Interface/Dialog.cs62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/Interface/Dialog.cs b/src/Interface/Dialog.cs
new file mode 100644
index 0000000..23f65d7
--- /dev/null
+++ b/src/Interface/Dialog.cs
@@ -0,0 +1,62 @@
+using Microsoft.Office.Interop.Excel;
+using System.Collections.Generic;
+using System.Windows.Forms;
+
+namespace RehauSku.Interface
+{
+ static class Dialog
+ {
+ public static string GetFilePath()
+ {
+ using (OpenFileDialog dialog = new OpenFileDialog())
+ {
+ dialog.Filter = "Файлы Excel (*.xls;*.xlsx;*.xlsm)|*.xls;*.xlsx;*.xlsm";
+
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ return dialog.FileName;
+ }
+
+ else return string.Empty;
+ }
+ }
+
+ public static string[] GetMultiplyFiles()
+ {
+ using (OpenFileDialog dialog = new OpenFileDialog())
+ {
+ dialog.Filter = "Файлы Excel (*.xls;*.xlsx;*.xlsm)|*.xls;*.xlsx;*.xlsm";
+ dialog.Multiselect = true;
+
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ return dialog.FileNames;
+ }
+
+ else return null;
+ }
+ }
+
+ public static void SaveWorkbookAs()
+ {
+ Workbook workbook = AddIn.Excel.ActiveWorkbook;
+
+ using (SaveFileDialog dialog = new SaveFileDialog())
+ {
+ dialog.FileName = workbook.Name;
+ dialog.Filter = "Файлы Excel (*.xls;*.xlsx;*.xlsm)|*.xls;*.xlsx;*.xlsm";
+
+ if (dialog.ShowDialog() == DialogResult.Cancel)
+ {
+ workbook.Close(false);
+ }
+
+ else
+ {
+ string fileName = dialog.FileName;
+ workbook.SaveAs(fileName);
+ }
+ }
+ }
+ }
+}