diff options
Diffstat (limited to 'Source/DataExport')
-rw-r--r-- | Source/DataExport/Exporter.cs | 49 |
1 files changed, 29 insertions, 20 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() { |