помогите исправить код для WinForms

у меня программа считывает данные таблицы Excel и записывает все в один массив, А мне надо, чтоб каждую строчку в отдельный массив.

И подключить кнопку(button1)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using OfficeOpenXml;

namespace Corrol
{
    public partial class Form1 : Form
    {

        private double[,] excelTable;
        private int totalRows = 0;
        private int totalColumns = 0;

        public Form1()
        {
            InitializeComponent();
        }

        private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            try
            {
                DialogResult res = openFileDialog1.ShowDialog();

                if (res == DialogResult.OK)
                {
                    ExcelPackage excelFile = new ExcelPackage(new FileInfo(openFileDialog1.FileName));

                    ExcelWorksheet worksheet = excelFile.Workbook.Worksheets[1];
                    totalRows = worksheet.Dimension.End.Row;
                    totalColumns = worksheet.Dimension.End.Column;
                    excelTable = new double[totalRows, totalColumns];
                    for (int rowIndex = 1; rowIndex <= totalRows; rowIndex++)
                    {
                        IEnumerable<string> row = worksheet.Cells[rowIndex, 1, rowIndex, totalColumns].Select(c => c.Value == null ? string.Empty : c.Value.ToString());
                        List<string> list = row.ToList<string>();

                        for (int i = 0; i < list.Count; i++)
                        {
                            excelTable[rowIndex - 1, i] = Convert.ToDouble(list[i].Replace('-', ','));

                        }
                    }
                    for (int i = 0; i < totalRows; i++)
                    {
                        for (int j = 0; j < totalColumns; j++)
                        {
                            richTextBox1.Text += Convert.ToString(excelTable[i, j]) + "     ";

                        }
                        richTextBox1.Text += "\n";
                    }
                }
                else
                {
                    throw new Exception("Файл не выбран");
                }



            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }
    }

    
}

Ответы (0 шт):