コード例 #1
0
        /// <summary>
        /// Обрабатывает событие нажатия на пункт меню "Загрузить из .xlsx"
        /// </summary>
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            clearForm();

            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Файлы Excel(*.xlsx)|*.xlsx";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                DataSelectionForm DSF = new DataSelectionForm();
                DSF.Owner = this;
                DSF.ShowDialog();

                switch (DSF.DialogResult)
                {
                case DialogResult.OK:
                {
                    numRowTable = countNumberRow(firstCell, lastCell);

                    dataGridView.Rows.Clear();

                    ExcelIO readExcel = new ExcelIO(openFileDialog.FileName, 1);
                    irrTextBox.Text = readExcel.readCell(irrCell);
                    actual          = readExcel.readRangeCell(firstCell, removeDigit(firstCell) + removeLetter(lastCell));
                    cumulativeProd  = readExcel.readRangeCell(removeDigit(lastCell) + removeLetter(firstCell), lastCell);
                    readExcel.close(false);

                    dataGridView.Rows.Add(numRowTable);

                    for (int i = 0; i < numRowTable; i++)
                    {
                        dataGridView.Rows[i].Cells[0].Value = actual[i];
                        dataGridView.Rows[i].Cells[1].Value = cumulativeProd[i];
                    }
                    initializationArray();
                    saveData();
                }
                break;

                case DialogResult.Abort:
                    MessageBox.Show("Неверный формат адреса ячейки.", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;

                default:
                    return;
                }
            }
            else
            {
                return;
            }
        }
コード例 #2
0
        /// <summary>
        /// Обрабатывает событие нажатия на пункт меню "Сохранить в .xlsx"
        /// </summary>
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter = "Файлы Excel(*.xlsx)|*.xlsx";

            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                ExcelIO writeExcel = new ExcelIO(saveFileDialog.FileName, 1);

                writeExcel.writeCell(2, 1, "НИЗ");
                writeExcel.writeCell(2, 2, irr);
                writeExcel.writeCell(2, 3, "тыс.т.");
                writeExcel.writeCell(3, 1, "ф-ия вида:  y = a * x + b ");
                writeExcel.writeCell(4, 1, "коэф-т a");
                writeExcel.writeCell(4, 2, incline);
                writeExcel.writeCell(4, 4, "коэф-т a");
                writeExcel.writeCell(4, 5, line);
                writeExcel.writeCell(5, 1, "Историч данные по %В (от 30% до макс).");
                writeExcel.writeCell(6, 1, "факт %В");
                writeExcel.writeCell(6, 2, "нак.доб");
                writeExcel.writeCell(6, 3, "%В_сред");
                writeExcel.writeCell(6, 4, "LN(WOR)");
                writeExcel.writeCell(6, 5, "отбНИЗ");
                writeExcel.writeColumn(7, 1, actual);
                writeExcel.writeColumn(7, 2, cumulativeProd);
                writeExcel.writeColumn(7, 3, avgActual);
                writeExcel.writeColumn(7, 4, lnWor);
                writeExcel.writeColumn(7, 5, mined);

                writeExcel.drawGraph(saveFileDialog.FileName, 1, firstCell, lastCell);

                writeExcel.close(true);
            }
            else
            {
                return;
            }
        }