RhSolutions-AddIn/RhSolutions.AddIn/Models/Dialog.cs

41 lines
1.1 KiB
C#
Raw Normal View History

2022-01-09 15:47:54 +03:00
using Microsoft.Office.Interop.Excel;
using System.Collections.Generic;
2021-12-24 16:22:03 +03:00
using System.Windows.Forms;
2022-12-20 12:27:47 +03:00
namespace RhSolutions.Models
2021-12-24 16:22:03 +03:00
{
static class Dialog
{
public static string GetFilePath()
{
using (OpenFileDialog dialog = new OpenFileDialog())
{
2021-12-24 17:42:20 +03:00
dialog.Filter = "Файлы Excel (*.xls;*.xlsx;*.xlsm)|*.xls;*.xlsx;*.xlsm";
2021-12-24 16:22:03 +03:00
if (dialog.ShowDialog() == DialogResult.OK)
{
2022-02-02 18:26:04 +03:00
return dialog.FileName;
2021-12-24 16:22:03 +03:00
}
else return string.Empty;
}
2021-12-24 16:22:03 +03:00
}
public static string[] GetMultiplyFiles()
{
using (OpenFileDialog dialog = new OpenFileDialog())
{
2021-12-24 17:42:20 +03:00
dialog.Filter = "Файлы Excel (*.xls;*.xlsx;*.xlsm)|*.xls;*.xlsx;*.xlsm";
2021-12-24 16:22:03 +03:00
dialog.Multiselect = true;
if (dialog.ShowDialog() == DialogResult.OK)
{
2022-02-02 18:26:04 +03:00
return dialog.FileNames;
2021-12-24 16:22:03 +03:00
}
2022-02-02 18:26:04 +03:00
else return null;
}
2021-12-24 16:22:03 +03:00
}
}
}