aboutsummaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorSergey Chebotar <s.chebotar@gmail.com>2021-12-09 09:14:19 +0300
committerSergey Chebotar <s.chebotar@gmail.com>2021-12-09 09:14:19 +0300
commitf8ec152378d5021386a8f145d5c7ff5026ba100e (patch)
tree99d6ddabeef484e0be4f0b6617caf56b6a4470be /Source
parentbc3421e67f7fd64ff0a7a0c078bbba6fbf971905 (diff)
Copy pricelist file
Diffstat (limited to 'Source')
-rw-r--r--Source/DataExport/Exporter.cs49
-rw-r--r--Source/Ribbon/RibbonController.cs2
2 files changed, 30 insertions, 21 deletions
diff --git a/Source/DataExport/Exporter.cs b/Source/DataExport/Exporter.cs
index d8b8380..069aca9 100644
--- a/Source/DataExport/Exporter.cs
+++ b/Source/DataExport/Exporter.cs
@@ -12,12 +12,12 @@ namespace RehauSku.DataExport
private Application xlApp;
private Dictionary<string, double> SkuAmount { get; set; }
private object[,] SelectedCells { get; set; }
- private string WorkingFileName { get; set; }
+ private string ActiveFilePath { get; set; }
public Exporter()
{
this.xlApp = (Application)ExcelDnaUtil.Application;
- this.WorkingFileName = xlApp.ActiveWorkbook.FullName;
+ this.ActiveFilePath = xlApp.ActiveWorkbook.Path;
GetSelectedCells();
}
@@ -73,31 +73,40 @@ namespace RehauSku.DataExport
}
}
- //public void FillPriceList()
- //{
- // string exportFileName = "rehau-export_" + DateTime.Now + ".xlsm";
- // string workingDir = xlApp.ActiveWorkbook.Path;
+ public void FillPriceList()
+ {
+
+ File.Copy(AddIn.priceListPath, _GetExportFileDir());
+
+ //Workbook wb = xlApp.Workbooks.Open(PriceListFilePath);
+ //Worksheet ws = wb.ActiveSheet;
- // //File.Copy(Path.GetFullPath(PriceListFilePath), Path.Combine(WorkingFileName, exportFileName + ".xlsm"));
+ //Range amountCell = ws.Cells.Find("Кол-во");
+ //foreach (KeyValuePair<string, double> kvp in SkuAmount)
+ //{
+ // Range cell = ws.Cells.Find(kvp.Key);
+ // ws.Cells[cell.Row, amountCell.Column].Value = kvp.Value;
+ //}
- // Workbook wb = xlApp.Workbooks.Open(PriceListFilePath);
- // Worksheet ws = wb.ActiveSheet;
+ ////Range filter = ws.Range["H16:H4058"];
+ //ws.Cells.AutoFilter(7, "<>");
- // Range amountCell = ws.Cells.Find("Кол-во");
+ ////wb.Save();
+ ////wb.Close();
+ }
- // foreach (KeyValuePair<string, double> kvp in SkuAmount)
- // {
- // Range cell = ws.Cells.Find(kvp.Key);
- // ws.Cells[cell.Row, amountCell.Column].Value = kvp.Value;
- // }
+ private string _GetExportFileDir()
+ {
+ string fileExtension = Path.GetExtension(AddIn.priceListPath),
+ exportFileName = "rehau-export-" + DateTime.Now.ToShortDateString(),
+ exportFilePath = !string.IsNullOrEmpty(ActiveFilePath) ?
+ ActiveFilePath :
+ Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
- // //Range filter = ws.Range["H16:H4058"];
- // ws.Cells.AutoFilter(7, "<>");
+ return Path.Combine(exportFilePath, exportFileName) + fileExtension;
+ }
- // //wb.Save();
- // //wb.Close();
- //}
public void Dispose()
{
diff --git a/Source/Ribbon/RibbonController.cs b/Source/Ribbon/RibbonController.cs
index 7402a09..7fa2ac8 100644
--- a/Source/Ribbon/RibbonController.cs
+++ b/Source/Ribbon/RibbonController.cs
@@ -37,7 +37,7 @@ namespace RehauSku.Ribbon
else
{
dw.FillSkuAmountDict();
- //dw.FillPriceList();
+ dw.FillPriceList();
}
}
}