Add SaveAs Dialog after export
This commit is contained in:
parent
0c307e985f
commit
846547d6d9
@ -1,6 +1,7 @@
|
|||||||
using ExcelDna.Integration;
|
using ExcelDna.Integration;
|
||||||
using ExcelDna.IntelliSense;
|
using ExcelDna.IntelliSense;
|
||||||
using ExcelDna.Registration;
|
using ExcelDna.Registration;
|
||||||
|
using Microsoft.Office.Interop.Excel;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Runtime.Caching;
|
using System.Runtime.Caching;
|
||||||
|
|
||||||
@ -20,6 +21,7 @@ namespace RehauSku
|
|||||||
{
|
{
|
||||||
public static HttpClient httpClient;
|
public static HttpClient httpClient;
|
||||||
public static MemoryCache memoryCache;
|
public static MemoryCache memoryCache;
|
||||||
|
public static Application Excel;
|
||||||
|
|
||||||
public void AutoOpen()
|
public void AutoOpen()
|
||||||
{
|
{
|
||||||
@ -28,6 +30,7 @@ namespace RehauSku
|
|||||||
RegisterFunctions();
|
RegisterFunctions();
|
||||||
IntelliSenseServer.Install();
|
IntelliSenseServer.Install();
|
||||||
RegistryUtil.Initialize();
|
RegistryUtil.Initialize();
|
||||||
|
Excel = (Application)ExcelDnaUtil.Application;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AutoClose()
|
public void AutoClose()
|
||||||
|
@ -2,56 +2,56 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using RehauSku.Forms;
|
using RehauSku.Forms;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using ExcelDna.Integration;
|
||||||
|
|
||||||
namespace RehauSku
|
namespace RehauSku
|
||||||
{
|
{
|
||||||
static class RegistryUtil
|
static class RegistryUtil
|
||||||
{
|
{
|
||||||
private static string _priceListPath;
|
private static string priceListPath;
|
||||||
private static int? _storeResponseOrder;
|
private static int? storeResponseOrder;
|
||||||
private static RegistryKey _RootKey { get; set; }
|
private static RegistryKey RootKey { get; set; }
|
||||||
|
|
||||||
public static void Initialize()
|
public static void Initialize()
|
||||||
{
|
{
|
||||||
_RootKey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\REHAU\SkuAssist");
|
RootKey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\REHAU\SkuAssist");
|
||||||
_priceListPath = _RootKey.GetValue("PriceListPath") as string;
|
priceListPath = RootKey.GetValue("PriceListPath") as string;
|
||||||
_storeResponseOrder = _RootKey.GetValue("StoreResponseOrder") as int?;
|
storeResponseOrder = RootKey.GetValue("StoreResponseOrder") as int?;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Uninitialize()
|
public static void Uninitialize()
|
||||||
{
|
{
|
||||||
_RootKey.Close();
|
RootKey.Close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsPriceListPathEmpty()
|
public static bool IsPriceListPathEmpty()
|
||||||
{
|
{
|
||||||
return string.IsNullOrEmpty(_priceListPath);
|
return string.IsNullOrEmpty(priceListPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string PriceListPath
|
public static string PriceListPath
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (IsPriceListPathEmpty() || !File.Exists(_priceListPath))
|
if (IsPriceListPathEmpty() || !File.Exists(priceListPath))
|
||||||
{
|
{
|
||||||
MessageBox.Show("Прайс-лист отсутствует или неверный файл прайс-листа", "Укажите файл прайс-листа", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
//MessageBox.Show("Прайс-лист отсутствует или неверный файл прайс-листа", "Укажите файл прайс-листа", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
string fileName = Dialog.GetFilePath();
|
string fileName = Dialog.GetFilePath();
|
||||||
_priceListPath = fileName;
|
priceListPath = fileName;
|
||||||
_RootKey.SetValue("PriceListPath", fileName);
|
RootKey.SetValue("PriceListPath", fileName);
|
||||||
return _priceListPath;
|
return priceListPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return _priceListPath;
|
return priceListPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_priceListPath = value;
|
priceListPath = value;
|
||||||
_RootKey.SetValue("PriceListPath", value);
|
RootKey.SetValue("PriceListPath", value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,16 +59,16 @@ namespace RehauSku
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_storeResponseOrder == null)
|
if (storeResponseOrder == null)
|
||||||
{
|
{
|
||||||
_RootKey.SetValue("StoreResponseOrder", (int)ResponseOrder.Default);
|
RootKey.SetValue("StoreResponseOrder", (int)ResponseOrder.Default);
|
||||||
_storeResponseOrder = (int)ResponseOrder.Default;
|
storeResponseOrder = (int)ResponseOrder.Default;
|
||||||
return (ResponseOrder)_storeResponseOrder.Value;
|
return (ResponseOrder)storeResponseOrder.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return (ResponseOrder)_storeResponseOrder.Value;
|
return (ResponseOrder)storeResponseOrder.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using Microsoft.Office.Interop.Excel;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace RehauSku.Forms
|
namespace RehauSku.Forms
|
||||||
@ -42,5 +43,20 @@ namespace RehauSku.Forms
|
|||||||
|
|
||||||
return fileNames.ToArray();
|
return fileNames.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SaveWorkbookAs()
|
||||||
|
{
|
||||||
|
Workbook wb = AddIn.Excel.ActiveWorkbook;
|
||||||
|
string currentFilename = wb.FullName;
|
||||||
|
string fileFilter = "Файлы Excel (*.xls;*.xlsx;*.xlsm),*.xls;*.xlsx;*.xlsm";
|
||||||
|
|
||||||
|
object fileName = AddIn.Excel.GetSaveAsFilename(currentFilename, fileFilter);
|
||||||
|
|
||||||
|
if (fileName.GetType() == typeof(string))
|
||||||
|
wb.SaveAs(fileName);
|
||||||
|
|
||||||
|
else
|
||||||
|
wb.Close(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,9 @@ namespace RehauSku.PriceListTools
|
|||||||
filter.Range.AutoFilter(offer.amountColumnNumber - firstFilterColumn + 1 + exportedLists, "<>");
|
filter.Range.AutoFilter(offer.amountColumnNumber - firstFilterColumn + 1 + exportedLists, "<>");
|
||||||
offer.Sheet.Range["A1"].Activate();
|
offer.Sheet.Range["A1"].Activate();
|
||||||
|
|
||||||
offer.Sheet.Application.StatusBar = $"Экспортировано {exportedValues} строк из {sourcePriceLists.Count} файлов";
|
AddIn.Excel.StatusBar = $"Экспортировано {exportedValues} строк из {sourcePriceLists.Count} файлов";
|
||||||
|
|
||||||
|
Forms.Dialog.SaveWorkbookAs();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
@ -113,7 +113,9 @@ namespace RehauSku.PriceListTools
|
|||||||
|
|
||||||
filter.Range.AutoFilter(offer.amountColumnNumber - firstFilterColumn + 1, "<>");
|
filter.Range.AutoFilter(offer.amountColumnNumber - firstFilterColumn + 1, "<>");
|
||||||
offer.Sheet.Range["A1"].Activate();
|
offer.Sheet.Range["A1"].Activate();
|
||||||
offer.Sheet.Application.StatusBar = $"Экспортировано {exportedValues} строк из {SkuAmount.Count}";
|
AddIn.Excel.StatusBar = $"Экспортировано {exportedValues} строк из {SkuAmount.Count}";
|
||||||
|
|
||||||
|
Forms.Dialog.SaveWorkbookAs();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
@ -52,7 +52,9 @@ namespace RehauSku.PriceListTools
|
|||||||
|
|
||||||
filter.Range.AutoFilter(offer.amountColumnNumber - firstFilterColumn + 1, "<>");
|
filter.Range.AutoFilter(offer.amountColumnNumber - firstFilterColumn + 1, "<>");
|
||||||
offer.Sheet.Range["A1"].Activate();
|
offer.Sheet.Range["A1"].Activate();
|
||||||
offer.Sheet.Application.StatusBar = $"Экспортировано {exportedValues} строк из {sourcePriceLists.Count} файлов";
|
AddIn.Excel.StatusBar = $"Экспортировано {exportedValues} строк из {sourcePriceLists.Count} файлов";
|
||||||
|
|
||||||
|
Forms.Dialog.SaveWorkbookAs();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
@ -31,7 +31,7 @@ namespace RehauSku.PriceListTools
|
|||||||
|
|
||||||
if (amountCell == null || skuCell == null)
|
if (amountCell == null || skuCell == null)
|
||||||
{
|
{
|
||||||
Sheet.Application.StatusBar = $"Лист {Name} не распознан";
|
AddIn.Excel.StatusBar = $"Лист {Name} не распознан";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,24 +40,30 @@ namespace RehauSku.Ribbon
|
|||||||
using (MergeTool mergeTool = new MergeTool())
|
using (MergeTool mergeTool = new MergeTool())
|
||||||
{
|
{
|
||||||
string[] files = Dialog.GetMultiplyFiles();
|
string[] files = Dialog.GetMultiplyFiles();
|
||||||
|
if (files.Length != 0)
|
||||||
|
{
|
||||||
mergeTool.GetSource(files);
|
mergeTool.GetSource(files);
|
||||||
string exportFile = PriceList.CreateNewFile();
|
string exportFile = RegistryUtil.PriceListPath;
|
||||||
mergeTool.OpenNewPrice(exportFile);
|
mergeTool.OpenNewPrice(exportFile);
|
||||||
mergeTool.FillPriceList();
|
mergeTool.FillPriceList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void OnCombinePressed(IRibbonControl control)
|
public void OnCombinePressed(IRibbonControl control)
|
||||||
{
|
{
|
||||||
using (CombineTool combineTool = new CombineTool())
|
using (CombineTool combineTool = new CombineTool())
|
||||||
{
|
{
|
||||||
string[] files = Dialog.GetMultiplyFiles();
|
string[] files = Dialog.GetMultiplyFiles();
|
||||||
|
if (files.Length != 0)
|
||||||
|
{
|
||||||
combineTool.GetSource(files);
|
combineTool.GetSource(files);
|
||||||
string exportFile = PriceList.CreateNewFile();
|
string exportFile = RegistryUtil.PriceListPath;
|
||||||
combineTool.OpenNewPrice(exportFile);
|
combineTool.OpenNewPrice(exportFile);
|
||||||
combineTool.FillPriceList();
|
combineTool.FillPriceList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void OnExportPressed(IRibbonControl control)
|
public void OnExportPressed(IRibbonControl control)
|
||||||
{
|
{
|
||||||
@ -66,7 +72,7 @@ namespace RehauSku.Ribbon
|
|||||||
using (ExportTool exportTool = new ExportTool())
|
using (ExportTool exportTool = new ExportTool())
|
||||||
{
|
{
|
||||||
exportTool.GetSource();
|
exportTool.GetSource();
|
||||||
string exportFile = PriceList.CreateNewFile();
|
string exportFile = RegistryUtil.PriceListPath;
|
||||||
exportTool.OpenNewPrice(exportFile);
|
exportTool.OpenNewPrice(exportFile);
|
||||||
exportTool.FillPriceList();
|
exportTool.FillPriceList();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user