Exemplo n.º 1
0
        public void CreateJobPacket()
        {
            DataAccess DB           = new DataAccess();
            string     prodSheetLoc = DB.GetHydroProdSheetLocation(PartNumber);
            //System.Windows.Forms.MessageBox.Show($"Prod Sheet Location = { prodSheetLoc }");
            bool isNewPath = true;

            if (string.IsNullOrEmpty(prodSheetLoc))
            {
                prodSheetLoc = @"C:\Dev\prodSheet18\masterAcmeHydroProdSheet.xlsx";
            }
            else
            {
                isNewPath = false;
            }
            SFPacket sfObj = new SFPacket()
            {
                item_no           = PartNumber,
                ord_no            = WorkOrder,
                cyc_per           = StdCycle,
                setup_std_lbr_hrs = SetupHours,
                RawMaterial       = RawMaterial,
                PieceWeight       = PieceWeight,
                qty = (int)OrderQty
            };

            ExcelInterop.popHydroProdSheet(prodSheetLoc, sfObj, isNewPath);
        }
Exemplo n.º 2
0
        private void excelWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            var       allData = (bool)e.Argument;
            DataTable dataToExport;

            if (allData)
            {
                dataToExport = table.GetData(this.filter);
            }
            else
            {
                dataToExport = this.data;
            }

            if (dataToExport != null)
            {
                var sheet = ExcelInterop.CreateWorksheet("", dataToExport, excelWorker);
                if (sheet != null)
                {
                    excelWorker.ReportProgress(100, "Loading Excel...");
                    sheet.OpenInExcel();
                }
                else
                {
                    e.Cancel = true;
                }
            }
        }
Exemplo n.º 3
0
 public void FetchDataErrors02()
 {
     using (var script = new VariableRHostScript()) {
         ExcelData xlData = ExcelInterop.GenerateExcelData("zzzzzz", 2, 2);
         xlData.Should().BeNull();
     }
 }
Exemplo n.º 4
0
        private void GerarTabela(object sender, RoutedEventArgs e)
        {
            List <List <string> > tabela;

            using (var excel = new ExcelInterop())
            {
                tabela = excel.LerTabela(textBoxExcel.Text);
            }

            if (_gramatica.NaoTerminais.Count == 0)
            {
                labelAviso.Content = "Nenhum Não-Terminal";
            }
            else if (_gramatica.NaoTerminais.All(nt => nt.Producoes.Count == 0))
            {
                labelAviso.Content = "Nenhuma produção";
            }
            else
            {
                labelAviso.Content = "";
                var wnd = new TabelaWindow(_gramatica, tabela);

                if (wnd.GerarTabelaLSR())
                {
                    wnd.Show();
                }
            }
        }
Exemplo n.º 5
0
        private string SavePreviewTemplate()
        {
            string extension = string.Empty;

            byte[] body = null;

            DownLoadTemplateFromBase(out extension, out body);
            //вложить в cache папку

            if (body == null || string.IsNullOrEmpty(extension))
            {
                return(string.Empty);
            }

            var pathForFormat = DirectoryPath + string.Format(@"\{0}{1}", TemplateID.ToString(), extension);

            try
            {
                File.WriteAllBytes(pathForFormat, body);
            }
            catch
            {
                throw new Exception(string.Format("Файл с расширением {0} не загрузился", extension));
            }

            try
            {
                if (TemplateType == "wordbased")
                {
                    using (var wi = new WordInterop())
                        wi.SaveWithHtmlExtension(pathForFormat);
                }
                else if (TemplateType == "excelbased")
                {
                    using (var ei = new ExcelInterop())
                        ei.SaveWithHtmlExtension(pathForFormat);
                }
            }

            catch
            {
#if EXCLUDED
                throw new Exception("Не сохранился файл с расширением html");
#endif
                return(string.Empty);
            }

            try
            {
                File.Delete(pathForFormat);
            }
            catch
            {
                throw new Exception(string.Format("Файл с расширением {0} не удалился", extension));
            }

            return(TemplateID.ToString() + ".html");
        }
Exemplo n.º 6
0
        public static void procesaFacturacion(string pathFacturas, string pathAvon)
        {
            ExcelInterop oEI = new ExcelInterop();

            Worksheet xlWorkSheet;
            Workbook  xlWorkBook;

            lstTransTarifa = readTransporteTarifa();
            lstManioTarifa = readManiobraTarifa();
            LogCtrl.writeLog("Termina lectura de tarifas...");
            xlWorkBook = oEI.openBook(pathFacturas);
            LogCtrl.writeLog("Comienza lectura de facturas...");
            List <factura> lst = new List <factura>();

            for (int i = 1; i <= xlWorkBook.Worksheets.Count; i++)
            {
                try
                {
                    xlWorkSheet = (Worksheet)xlWorkBook.Worksheets.get_Item(i);
                    lst.Add(procesaHoja(xlWorkSheet));
                    xlWorkSheet = null;
                }
                catch (Exception e) {
                    LogCtrl.writeLog(e.Message);
                }
            }

            oEI.closeBook(xlWorkBook);
            Console.WriteLine("Lectura de facturas completa");


            #region Crea xls Avon

            xlWorkBook  = oEI.openBook(getPathFile("PlantillaAvon.xlsx"));
            xlWorkSheet = (Worksheet)xlWorkBook.Worksheets.get_Item(1);
            insertaParcialesColumnas(xlWorkSheet);//Inserta tantas columnas como el máximo número de parciales que se hayan registrado

            int fila = 2;
            foreach (factura item in lst)
            {
                try
                {
                    insertaFila(xlWorkSheet, fila, item);
                    fila++;
                }
                catch { }
            }
            Console.WriteLine("Escritura de facturas en la plantilla completa");

            oEI.saveXls(xlWorkBook, xlWorkSheet, pathAvon.Replace("/", @"\"));

            #endregion

            //Console.Read();
        }
Exemplo n.º 7
0
        void applyButton_Click(object sender, RoutedEventArgs e)
        {
            String startCell = this.CellFromTextBox.Text;
              String endCell = this.CellToTextBox.Text;
              String column = this.ColumnTextBox.Text;
              ExcelInterop interop = new ExcelInterop(ExcelInterop.ActiveExcel);
              IList cells = interop.ObtainCells(column, startCell, endCell);

              //                      DisplayDerivedDataType(typeOfCells);
              //                      DisplayOperationsForType(typeOfCells);

              // Perform operation.
        }
Exemplo n.º 8
0
        public override void Cleanup()
        {
            try
            {
                base.Cleanup();

                EventArgs args = new ExcelCloseEventArgs(false);
                ExcelInterop.OnProcessExit(this, args);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }
Exemplo n.º 9
0
        private void excelWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            var data = this.DataTable;

            if (data != null)
            {
                var sheet = ExcelInterop.CreateWorksheet("", data, excelWorker);
                if (sheet != null)
                {
                    excelWorker.ReportProgress(100, "Loading Excel...");
                    sheet.OpenInExcel();
                }
                else
                {
                    e.Cancel = true;
                }
            }
        }
Exemplo n.º 10
0
        public override void Cleanup()
        {
            try
            {
                EventArgs args = new ExcelCloseEventArgs(false);
                ViewModel.Model.ShutDown(false);
                this.ViewModel = null;
                ExcelInterop.OnProcessExit(this, args);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }

            base.Cleanup();

            GC.Collect();
        }
Exemplo n.º 11
0
        public async Task FetchData()
        {
            using (var script = new VariableRHostScript()) {
                var o = await GetMtCars(script);

                o.Should().NotBeNull();

                ExcelData xlData = ExcelInterop.GenerateExcelData("x", o.Dimensions[0], o.Dimensions[1]);

                int rows = o.Dimensions[0];
                int cols = o.Dimensions[1];

                xlData.CellData.GetLength(0).Should().Be(rows);
                xlData.CellData.GetLength(1).Should().Be(cols);

                xlData.RowNames.Length.Should().Be(rows);
                xlData.ColNames.Length.Should().Be(cols);

                xlData.CellData[0, 0].Should().Be("21.0");
                xlData.CellData[rows - 1, cols - 1].Should().Be("2");
            }
        }
Exemplo n.º 12
0
        public override void Cleanup()
        {
            try
            {
                var shutdownParams = new DynamoViewModel.ShutdownParams(
                    shutdownHost: false, allowCancellation: false);

                ViewModel.PerformShutdownSequence(shutdownParams);
                this.ViewModel = null;

                EventArgs args = new ExcelCloseEventArgs(false);
                ExcelInterop.OnProcessExit(this, args);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }

            base.Cleanup();

            GC.Collect();
        }
Exemplo n.º 13
0
        public void FetchDataErrors01()
        {
            ExcelData xlData = ExcelInterop.GenerateExcelData("x", -10, -10);

            xlData.Should().BeNull();
        }
Exemplo n.º 14
0
 private void OpenInExcel(object parameter)
 {
     ExcelInterop.OpenDataInExcel(Name, Expression, Dimensions[0], Dimensions[1]);
 }
        private void button_Click(object sender, EventArgs e)
        {
            if (outputRunning)
            {
                Debug.WriteLine("ITS ALREADY RUNNING!!!");
                return;
            }

            outputRunning = true;
            short            customerID   = (short)this.customer_select_combobox.SelectedValue;
            string           customerName = this.customer_select_combobox.Text;
            String           fileName     = "C:\\Users\\Public\\" + customerName + "_scorecard.xlsx";
            BackgroundWorker bw           = new BackgroundWorker();

            // this allows our worker to report progress during work
            bw.WorkerReportsProgress = true;

            // this lets us cancel processing if we hit an error
            bw.WorkerSupportsCancellation = true;

            // what to do when progress changed - we'll update our output to indicate that we've done something
            bw.ProgressChanged += new ProgressChangedEventHandler(
                delegate(object o, ProgressChangedEventArgs args)
            {
                string progressString = args.UserState.ToString();
                if (args.ProgressPercentage == -1)
                {
                    this.output.Text = this.output.Text + progressString + "\n";
                }
                else
                {
                    this.output.Text = this.output.Text + "Did something: " + progressString + "\n";
                }
            }
                );

            // what to do when worker completes its task (notify the user)
            bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(
                delegate(object o, RunWorkerCompletedEventArgs args)
            {
                if (args.Cancelled == true)
                {
                    this.output.Text = this.output.Text + "Cancelled!\n";
                }
                else
                {
                    this.output.Text = this.output.Text + "Finished!\nFile located at: " + fileName + "\n";
                }
            }
                );

            // what to do in the background thread
            bw.DoWork += new DoWorkEventHandler(
                delegate(object o, DoWorkEventArgs args)
            {
                BackgroundWorker b        = o as BackgroundWorker;
                CustomerData customerData = GetCustomerData(customerID, b);
                if (customerData == null)
                {
                    args.Cancel = true;
                }
                else
                {
                    ExcelInterop excelInterop = new ExcelInterop();
                    if (excelInterop.CreateWorkbook(fileName, customerData, b))
                    {
                        b.ReportProgress(30, "Scorecard saved!");
                    }
                    else
                    {
                        b.ReportProgress(-1, "Failed to Create Scorecard!");
                        b.CancelAsync();
                        args.Cancel = true;
                    }
                }
            }
                );

            bw.RunWorkerAsync();
            outputRunning = false;
        }
Exemplo n.º 16
0
 public override void Cleanup()
 {
     // suppress SaveAs by using this method
     ExcelInterop.TryQuitAndCleanupWithoutSaving();
     base.Cleanup();
 }
Exemplo n.º 17
0
 public override void Cleanup()
 {
     ExcelInterop.TryQuitAndCleanup(false);
     base.Cleanup();
 }